akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;

using namespace std;

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

    for (int i = s.size()-t.size(); i >= 0; i--){
	if ((t[0] == s[i]) || (s[i] == '?')){
	    bool can = true;
	    for (int j = 0; j < t.size(); j++){
		if ((s[i+j] != t[j]) && (s[i+j] != '?')){
		    can = false;
		}
	    }

	    if (can){
		for (int j = 0; j < s.size(); j++){
		    if (j == i){
			cout << t;
			j += t.size()-1;
		    } else {
			if (s[j] == '?') cout << 'a';
			else cout << s[j];
		    }
		}
		cout << endl;
		return 0;
	    }
	}
    }

    cout << "UNRESTORABLE" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    int n; cin>>n; int a[n]; int key=0,ans=0;
    for (int i = 0; i < n; i++)cin>>a[i];
    for (int i = n-1; i >= 1; i--){
        if(a[i-1]>=a[i])key++;
        else{
            chmax(ans,key); key=0;
        }
        chmax(ans,key);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> a(n);
    unordered_map<int64_t, int64_t> um;
    for (auto&& aa : a) {
        cin >> aa;
        ++um[aa];
    }

    int64_t t = 0;
    for (auto kv : um) {
        t += kv.second * (kv.second - 1) / 2;
    }

    for (auto aa : a) {
        cout << t - (um[aa] - 1) << "\n";
    }
}

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

constexpr int INF = (1<<30)-1;

string S;
int dfs(int left, int right) {
    if (isdigit(S[left + 1])) return ((stoi(S.substr(left + 1, right - left - 2)) + 1) / 2);
    vector<int> vec;
    int cnt = 0, l, sum = 0;
    for (int i = left + 1; i < right - 1; i++) {
        if (S[i] == '[') {
            if (cnt == 0) l = i;
            cnt++;
        } else if (S[i] == ']') {
            if (cnt == 1) vec.push_back(dfs(l, i + 1));
            cnt--;
        }
    }
    sort(begin(vec), end(vec));
    for (int i = 0; i < (vec.size() + 1) / 2; i++) sum += vec[i];
    return (sum);
}

void solve() {
    cin >> S;
    cout << dfs(0, S.size()) << endl;
    return;
}

int main() {
    int N;
    cin >> N;
    while (N--) solve();
    return (0);
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
const int vmax=100005;
int par[vmax];
void init(int x){
  for(int i=0;i<x;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){
  x=root(x);
  y=root(y);
  if(x==y){
    return ;
  }
  par[x]=y;
}
int main(){
  int v,e;cin >> v >> e;
  init(v);
  vector<pair<int,pair<int,int>>> a(e);
  for(int i=0;i<e;i++){
    int s,t,w;cin >> s >> t >> w;
    a[i]=make_pair(w,make_pair(s,t));
  }
  sort(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<e;i++){
    int w=a[i].first;
    int s=a[i].second.first;
    int t=a[i].second.second;
    if(root(s)!=root(t)){
      unite(s,t);
      ans+=w;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4120
object Main {
    def main(args : Array[String]) : Unit = {
        val a = io.StdIn.readLine().split(" ").map(_.toInt)
        if (a(0) < a(1)) {
            println(if (a(1) < a(2)) "Yes" else "No")
        } else println("No")
    }
}

Measured memory_bytes: 43768
A, B, C= map(int, input().split(' '))
K = int(input())
count = 0

while A >= B:
    B = 2 * B
    count += 1

while B >= C:
    C = 2*C
    count += 1

if count <= K:
    print("Yes")
elif count > K:
    print("No")

Measured memory_bytes: 9176
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim N As Integer
        N = console.ReadLine()
        Dim A() As Integer
        A = Array.ConvertAll(Of String, Integer)(Split(Console.ReadLine()), AddressOf Integer.Parse)
        Dim flg As Boolean = True
        For Each Ai As Integer In A
            If Ai Mod 2 = 0 AndAlso Ai Mod 3 <> 0 AndAlso Ai Mod 5 <> 0 Then
                flg = False
                Exit For
            End If
        Next
        console.WriteLine(If(flg, "APPROVED", "DENIED"))
    End Sub
End Class


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

int main()
{
	int N,Y,x,y,z;
	
	cin>>N>>Y;
	
	for(x=0;x<=Y/10000;x++)
	  for(y=0;y<=Y/5000;y++)
	  {
	  	z=N-x-y;
	  	if(z>=0 &&x*10000+y*5000+z*1000==Y)
	  	{
	  		cout<<x<<" "<<y<<" "<<z;
	  		return 0;
	  	}
	  }
	  cout<<"-1 -1 -1";
	  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
map<int,pair<int,int> >max_p,min_p;
map<char,int>mc;
int h,w,c,vis[101];
string s[51];
inline void mae(){
  r(i,h)r(j,w)
   if(s[i][j]=='.')s[i][j]='0';
   else{
    if(mc[s[i][j]])s[i][j]=mc[s[i][j]];
    else{
      mc[s[i][j]]=(c++)+'0';
      s[i][j]=(c-1)+'0';
    }
   }
}
inline void in(){
  for(int k=1;k<c;k++){
    int px=0,py=0,mx=1000,my=1000;
    r(i,h)r(j,w)
      if(s[i][j]-'0'==k){
        px=max(px,j);
        py=max(py,i);
        mx=min(mx,j);
        my=min(my,i);
      }
    max_p[k]=mk(px,py);
    min_p[k]=mk(mx,my);
  }
}
inline bool dfs(int d,int x){
  if(d){
    pair<int,int>p1=min_p[x],p2=max_p[x];
    for(int i=p1.se;i<=p2.se;i++)
      for(int j=p1.fi;j<=p2.fi;j++)
        if(!vis[s[i][j]-'0'])return 0;
  }
  if(d==c-1)return 1;
  for(int i=1;i<c;i++)
    if(!vis[i]){
      vis[i]=1;
      if(dfs(d+1,i))return 1;
      vis[i]=0;
    }
  return 0;
}
int main(){
  int n;
  cin>>n;
  while(n--){
    memset(vis,0,sizeof(vis));
    max_p.clear();
    min_p.clear();
    mc.clear();c=1;
    cin>>h>>w;
    r(i,h)cin>>s[i];
    mae();in();
    if(dfs(0,0))cout<<"SAFE"<<endl;
    else cout<<"SUSPICIOUS"<<endl;
  }
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll n, res=0, maxim=0;
    cin >> n;
    // vector<ll> a;
    rep(i, n){
        ll x;
        cin >> x;
        res += max(0LL, maxim - x);
        maxim = max(maxim, x);
        // a.push_back(x);
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int>p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i,k){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <map>

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

int dd[4] = { -1, 1, 4, -4 };

int swap(int s, int a, int b) {
	int buf[8];
	rep(i, 8) { buf[i] = s%8; s/=8; }
	swap(buf[a], buf[b]);
	int r=0;
	rep(i, 8) { r*=8; r+=buf[7-i]; }
	return r;
}

int main()
{
	int answer=0;
	rep(i, 8) { answer*=8; answer+=(7-i); }
	queue<pair<int, int> > q;
	q.push(make_pair(0, answer));
	map<int, int> dp;
	dp[answer] = 0;
	while(!q.empty()) {
		int c = q.front().first;
		int v = q.front().second;
		q.pop();
		int lz=-1;
		int t = v;
		rep(i, 8) {
			if(t%8==0) { lz=i; break; }
			t /= 8;
		}
		rep(d, 4) {
			if(0<=lz+dd[d] && lz+dd[d]<8
				&& !(lz==3 && dd[d]==1 || lz==4 && dd[d]==-1)) {
					int nv = swap(v, lz+dd[d], lz);
					if(dp.find(nv)!=dp.end()) continue;
					dp[nv] = c+1;
					q.push(make_pair(c+1, nv));
			}
		}
	}
	int buf[8];
	while(scanf("%d", buf)!=EOF) {
		rep(i, 7) scanf("%d", buf+i+1);
		int s = 0;
		rep(i, 8) { s*=8; s+=buf[7-i]; }
		printf("%d\n", dp[s]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vector<ll> d(N);
  REP(i,N) cin >> d[i];
  ll ans = 0;
  REP(i,N-1)REP2(j,i+1,N){
      ans += d[i]*d[j];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

ans = 0
for i in range(1, N):
    sj = set()
    sk = set()
    for j in range(i):
        sj.add(S[j])
    for k in range(i, N):
        sk.add(S[k])
    ans = max(len(sj & sk), ans)
    
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if(v <= w){
    cout << "NO" << endl;
    return 0;
  }

  ll d = abs(a-b);
  ll d2 = (v-w) * t;
  if(d <= d2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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

  
int main(){
 int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >>a.at(i);
  sort(a.begin(),a.end());
  cout << a.at(n-1)-a.at(0);
 }
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, K;
int x[100], y[100];

bool check(int top, int bottom, int right, int left) {
  int cnt = 0;
  rep(k, 0, N) {
    int cx = x[k];
    int cy = y[k];
    if (left <= cx && cx <= right && bottom <= cy && cy <= top) {
      ++cnt;
    }
  }

  return cnt >= K;
}

int dummy[1000000];

int main() {
  cin >> N >> K;
  rep(i, 0, N) { cin >> x[i] >> y[i]; }

  rep(i, 0, pow(N, 4)) { dummy[i % 1000000] = i; }

  ll ans = numeric_limits<ll>::max();
  rep(i, 0, N) {
    rep(j, i, N) {
      rep(k, j, N) {
        rep(l, k, N) {
          ll top = max(y[i], max(y[j], max(y[k], y[l])));
          ll bottom = min(y[i], min(y[j], min(y[k], y[l])));
          ll left = min(x[i], min(x[j], min(x[k], x[l])));
          ll right = max(x[i], max(x[j], max(x[k], x[l])));

          if (check(top, bottom, right, left)) {
            chmin(ans, (top - bottom) * (right - left));
          }
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 7944
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int[] AB=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    if(AB[0]>8||AB[1]>8)Console.WriteLine(":(");
    else Console.WriteLine("Yay!");
    
  }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
          
using namespace std;
          
#define ll long long
#define vi vector<int> 
#define pb push_back
#define sz(s) (int)s.size() 
#define all(v) v.begin(), v.end()
#define show(a) cerr << #a <<" -> "<< a <<"\n"
 
ll mn = 1000000, mx = -1000000000; 
ll cnt, cnt2, sum, x, y;
int a, b, c, d;
			             
int main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b >> c >> d;
    for (int i = 0; i < 10000; i++) {
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			return 0;
		}
		a -= d;
		if (a <= 0) {
    		cout << "No";
    		return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>

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

using namespace std;

typedef vector<int> vi;

void pp(vi v){
	rep(i, v.size()){
		cout << v[i] << ' ';
	}
	cout << endl;
}

int simulate(int init, int years, int type, double rate, int charge){
	int intsum = 0;	// 利子合計
	int interest;	// 利子
	rep(i, years){
		interest = init*rate;
		init -= charge;
		if(type == 0){	// 単利
			intsum += interest;
		}else{			// 複利
			init += interest;
		}
	}
	return init + intsum;
}

void test_simulate(){
	cout << simulate(1000000, 5, 0, 0.03125, 3000) << endl;
	cout << simulate(1000000, 5, 1, 0.03125, 3000) << endl;
}

int main(){
	//test_simulate();
	//return 0;

	int m;
	cin >> m;
	while(m--){
		int init;	// 初期資金
		int years;	// 運用年数

		cin >> init >> years;

		int best = init;
		int n;
		cin >> n;
		while(n--){
			int type;		// 0:単利 1:複利
			double rate;	// 利率
			int charge;		// 手数料
			cin >> type >> rate >> charge;
			best = max(best, simulate(init, years, type, rate, charge));
		}
		cout << best << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
//#pragma GCC optimize(3)
//#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=0;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int h,w,k;
string s[810];
queue<pii> q;
int len[810][810];
inline int minf(int a,int b,int c,int d){
	return min(a,min(b,min(c,d)));
}
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>h>>w>>k;
	rep(i,h){
		cin>>s[i];
	}
	int sx,sy;
	rep(i,h)rep(j,w){
		if(s[i][j]=='S'){
			sx=i;sy=j;
		}
	}
	s[sx][sy]='.';
	q.push(mp(sx,sy));
	len[sx][sy]=1;
	int dist=INF;
	while(!q.empty()){
		pii p=q.front();
		q.pop();
		int x=p.fi,y=p.sc;
		int d=min(x,min(h-x-1,min(y,w-y-1)));
		dist=min(dist,d);
		if(len[x][y]>k)goto escape;
		rep(i,4){
			int xx=x+dx[i],yy=y+dy[i];
			if(xx>=0&&xx<h&&yy>=0&&yy<w&&s[xx][yy]=='.'&&len[xx][yy]==0){
				len[xx][yy]=len[x][y]+1;
				q.push(mp(xx,yy));
			}
		}
		escape:;
	}
	cout<<(dist+k-1)/k+1;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
long long c[100];
int main()
{
	string str;
	long long s,i,n;
	cin >> str;
	s=str.size();
	n=s*(s-1)/2;
	for(i=0; i<s; i++)
		c[str[i]-97]++;
	for(i=0; i<26; i++)
	{
		n-=c[i]*(c[i]-1)/2;
	}
	cout << n+1;
}


Measured memory_bytes: 640
using System;

class Test
{
    public static void Main()
    {
        string s = Console.ReadLine();
        
        string[] ss = s.Split(' ');
        
        
        int m = int.Parse(ss[0]) * int.Parse(ss[1]);
        int n = (int.Parse(ss[0]) + int.Parse(ss[1])) * 2;
        
        Console.WriteLine(m + " " + n);
        
    }
}


Measured memory_bytes: 15940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool isfound[100009];
vector<vector<pair<int, bool>>> V(100001);

bool col[100009]; // 1:白
				  // 0:黒

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

	int N; cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int tmp1, tmp2, w;
		cin >> tmp1 >> tmp2 >> w;
		bool isodd = w % 2;
		V[tmp1].push_back(pair<int, bool>(tmp2, isodd));
		V[tmp2].push_back(pair<int, bool>(tmp1, isodd));
	}

	// 幅優先探索
	queue<int> Q;
	col[1] = 1;
	isfound[1] = true;
	Q.push(1);
	while (!Q.empty()) {
		int pos = Q.front();
		Q.pop();

		for (int i = 0; i < V[pos].size(); i++) {
			int npos = V[pos][i].first;
			if (!isfound[npos]) {
				isfound[npos] = true;
				Q.push(npos);

				// 距離が奇数なら
				if (V[pos][i].second) col[npos] = !col[pos];
				else col[npos] = col[pos];
			}
		}

	}

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

	return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
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;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
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 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;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
void nckinit(ll n,ll md){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=md;
  }
  gya[n]=gyaku(kai[n],md);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=md;
  }
  gya[0]=1;
}
ll nck(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  ret*=gya[k];
  ret%=md;
  return ret;
}
ll npk(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  return ret;
}
bool f(string s){
    string t=s;
    reverse(t.begin(),t.end());
    rep(i,0,s.size()){
        if(s[i]!=t[i])return false;
        
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    int n=s.size();
    string t=s.substr(0,(n-1)/2);
    string u=s.substr((n+3)/2-1);
    if(f(s)&&f(t)&&f(u))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}







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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
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 dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<ll> a(n-1),b(n-1),c(n);
  rep(i,n-1)cin>>a[i]>>b[i];
  rep(i,n)cin>>c[i];

  vector<ll> deg(n),cost(n,-1);
  vector<vector<ll>> adj(n);
  rep(i,n-1){
    a[i]--;b[i]--;
    adj[a[i]].push_back(b[i]);
    adj[b[i]].push_back(a[i]);
    deg[a[i]]++;
    deg[b[i]]++;
  }
  sort(c.begin(),c.end(),greater<>());

  ll degmax=0,degidx=0;
  rep(i,n){
    if(deg[i]>degmax){
      degmax=deg[i];
      degidx=i;
    }
  }

  using pll=pair<ll,ll>;
  priority_queue<pll> que;
  que.emplace(degmax,degidx);
  ll cidx=0;
  while(!que.empty()){
    ll d,v;
    tie(d,v)=que.top();
    que.pop();
    if(cost[v]!=-1)continue;
    cost[v]=c[cidx];
    cidx++;
    for(const auto& nv:adj[v]){
      if(cost[nv]!=-1)continue;
      deg[nv]--;
      que.emplace(deg[nv],nv);
    }
  }

  vector<ll> e(n-1);
  rep(i,n-1){
    e[i]=min(cost[a[i]],cost[b[i]]);
  }
  ll ans=0;
  for(auto x:e)ans+=x;
  cout<<(ans)<<endl;
  for(auto x:cost)cout<<x<<" ";cout<<endl;


}


Measured memory_bytes: 1668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  vector<int> a(5);
  int k;
  rep(i,5) {
    cin >> a[i];
  }
  cin >> k;

  sorti(a);

  if (abs(a.front() - a.back()) <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}


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

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define x first
#define y second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif


// __gcd(x, y)

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

    int k;
    cin >> k;
    string s;
    cin >> s;

    if(s.size() <= k)
        cout << s;
    else
    {
        string st = s.substr(0, k);
        st.append("...");
        cout << st << endl;
    }
    return 0;
}



Measured memory_bytes: 3556
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;



int main(){
    double a,b,c,d,e,f;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
        double x=(c*e-b*f)/(a*e-b*d);
        double y=(c-a*x)/b;

        if(abs(x)<1e-10){
            x=0;
        }
        if(abs(y)<1e-10){
            y=0;
        }
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}

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

int main() {
	string S;
	cin>>S;
	int N = S.size();
	bool f = true;
	string T = "";
	int cnt = 0;
	for (int i = N-1; i >= 0; --i){
		T+=S[i];
		cnt = T.size();
		if(cnt == 5){
			if(T == "maerd"||T == "esare"){
				T ="";
			}
			else continue;
		}
		else if(cnt == 6){
			if(T == "resare"){
				T = "";
			}
		}
		else if(cnt == 7){
			if(T == "remaerd"){
				T = "";
			}
			else{
				f = false;
				break;
			}
		}
	}
	string ans = "NO";
	if(f)ans = "YES";
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if (a < b)
	{
		printf("a < b\n");
	}
	if (a > b)
	{
		printf("a > b\n");
	}
	if (a == b)
	{
		printf("a == b\n");
	}
	return 0;
}

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

int main(){
    double r, ans;
    cin >> r;
    ans = r * 2.0 * 3.141592653589;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        n: usize,
        a: [usize; n],
    }
    let mut sum = 0;
    for i in 0..n {
        sum += a[i];
    }
    if sum >= h {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int h,w;cin>>h>>w;
  vector<vector<string>> s(h,vector<string>(w));
  rep(i,h){
    rep(j,w){
      cin>>s[i][j];
    }
  }
  rep(j,w){
    rep(i,h){
      if(s[i][j]=="snuke"){
        char res='A'+j;
        cout<<res<<i+1<<endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

// ax + by = gcd(a, b) となるような (x, y) を求める
// a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰
    y -= a / b * x;
    return d;
}


// 負の数に対応した mod
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}


// 逆元計算 (a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // x % m だが、x が負かもしれないので
}

int main() {
    int n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n)cin >> a[i];
    vector<ll> plus, minus, zero;
    rep(i,n){
        if(a[i] > 0)plus.push_back(a[i]);
        if(a[i] < 0)minus.push_back(a[i]);
        if(a[i] == 0)zero.push_back(a[i]);
    }
    n = plus.size();
    int m = minus.size();
    int w = zero.size();
    sort(plus.begin(), plus.end(), greater<ll>());
    sort(minus.begin(), minus.end());

    ll ans = 1;
    ll MOD = 1e9+7;

    if(n + m < k){
        cout << 0 << endl;
        return 0;
    }

    else if(n == 0){
        if(k % 2 == 0){
            rep(i,k){
                ans *= abs(minus[i]);
                ans %= MOD;
            }
        }else if(w > 0){
            ans = 0;
        }else{
            rep(i,k){
                ans *= abs(minus[m-1-i]);
                ans %= MOD;
            }
            ans = MOD - ans;
        }
    }

    else if(n + m == k && w == 0){
        rep(i,n){
            ans *= plus[i];
            ans %= MOD;
        }
        rep(i,m){
            ans *= MOD + minus[i];
            ans %= MOD;
        }
    }

    else{ // 最初にn,m,kをすべて偶数にしてしまう.
        if(k % 2 == 0){
            if(n % 2 == 1){
                plus.erase(plus.begin() + n - 1);
                n--;
            }
            if(m % 2 == 1){
                minus.erase(minus.begin() + m - 1);
                m--;
            }
        }else{
            ans *= plus[0];
            plus.erase(plus.begin());
            n--;
            k--;
            if(n % 2 == 1){
                plus.erase(plus.begin() + n - 1);
                n--;
            }
            if(m % 2 == 1){
                minus.erase(minus.begin() + m - 1);
                m--;
            }
        }
        vector<ll> v;
        rep(i,n/2){
            v.push_back(plus[i*2] * plus[i*2+1]);
        }
        rep(i,m/2){
            v.push_back(minus[i*2] * minus[i*2+1]);
        }
        sort(v.begin(), v.end(), greater<ll>());
        rep(i,k/2){
            ans *= v[i] % MOD;
            ans %= MOD;
        }
    }


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




Measured memory_bytes: 8104
#include <cstdio>
#include <utility>

int main(void) {
	int n, l;
	int aji[200];
	int sum = 0;

	scanf("%d %d", &n, &l);

	for(int i = 0; i < n; i++) {
		aji[i] = l + i;
		sum += aji[i];
	}

	int result;

	if(aji[0] < 0 && aji[n - 1] > 0) {
		result = sum;
	} else if(aji[0] < 0) {
		result = sum - aji[n - 1];
	} else {
		result = sum - aji[0];
	}

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

Measured memory_bytes: 128
aa = input()
bb = input()
cc = input()
def kansu(char,a,b,c):    
    if char == 'a':
        if not a:
            return 'A'
        else:
            char = a[0:1]
            a = a[1:]
            r = kansu(char,a,b,c)
    elif char == 'b':
        if not b:
            return 'B'
        else:
            char = b[0:1]
            b = b[1:]
            r = kansu(char,a,b,c)
    else:
        if not c:
            return 'C'
        else:
            char = c[0:1]
            c =c[1:]
            r = kansu(char,a,b,c)
    return r
            
charc = aa[0:1]
aa = aa[1:]
result = kansu(charc,aa,bb,cc)
print(result)

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

int main(void){
   int a;
   int L[10000];
   scanf("%d", &a);
   for (int i = 0; i < a; i++) {
      scanf("%d",&L[i] );
   }
   int ans = 0;
   for (int i = 0; i < a; i++) {
      ans += L[i] - 1;
   }
   printf("%d\n",ans);
   return 0;


}


Measured memory_bytes: 128
n = int(input())
a_ls = [0] * n
b_ls = [0] * n
c_ls = [0] * n
for i in range(n):
    a,b,c = map(int,input().split())
    a_ls[i] = a
    b_ls[i] = b
    c_ls[i] = c

dp = [[0]*3 for _ in range(n)]
dp[0] = [a_ls[0], b_ls[0], c_ls[0]]
for i in range(1,n):
    dp[i][0] = max(dp[i][0], dp[i-1][1] + a_ls[i], dp[i-1][2] + a_ls[i])
    dp[i][1] = max(dp[i][1], dp[i-1][0] + b_ls[i], dp[i-1][2] + b_ls[i])
    dp[i][2] = max(dp[i][2], dp[i-1][0] + c_ls[i], dp[i-1][1] + c_ls[i])
print(max(dp[-1]))


Measured memory_bytes: 34632
#include <cstdio>

int main(){
    int S, h, m, s;
    scanf("%d", &S);
    h = S/3600 - (S%3600)/3600;
    m = (S%3600)/60 - ((S%3600)%60)/60;
    s = (S%3600)%60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2712
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=chomp(readline())
    cnt=0
    for i in 1:200
        if i>length(s)
            break
        end
        if s[i]==')'
            if cnt>0
                cnt-=1
            else
                s="("*s
                cnt+=1
            end
        else
            cnt+=1
        end
    end
    cnt=0
    for i in 200:-1:1
        if i>length(s)
            continue
        end
        if s[i]=='('
            if cnt>0
                cnt-=1
            else
                s*=")"
            end
        else
            cnt+=1
        end
    end
    println(s)
end
main()

Measured memory_bytes: 111372
#include<bits/stdc++.h>
#define mxn 500005
#define xx first
#define yy second
using namespace std;
int lst[mxn], seg[mxn];
void add(int x, int n, int v)
{
    while(x<=n)
    {
        seg[x]+= v;
        x+= (x&-x);
    }
    return;
}
int query(int x)
{
    int ret= 0;
    while(x>0)
    {
        ret+= seg[x];
        x-= (x&-x);
    }
    return ret;
}
typedef pair<int, int>pi;
pi rng[mxn];
vector<pi>vec;
int res[mxn], ara[mxn];
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++)scanf("%d", &ara[i]);
    for(int i=0; i<q; i++)
    scanf("%d %d", &rng[i].xx, &rng[i].yy), vec.push_back({ rng[i].yy, i });
    sort(vec.begin(), vec.end());
    for(int i=1, j=0; i<=n && j<vec.size(); i++)
    {
        add(i, n, 1);
        if(lst[ ara[i] ])add(lst[ ara[i] ], n, -1);
        lst[ ara[i] ]= i;
        while(vec[j].xx==i)
        {
            res[ vec[j].yy ]= query(rng[ vec[j].yy ].yy)-query(rng[ vec[j].yy ].xx-1);
            j++;
        }
    }
    for(int i=0; i<q; i++)printf("%d\n", res[i]);
    return 0;
}


Measured memory_bytes: 19488
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
char S[200200];
bool rock2(int x, int y) {
    if(x >= y) return false;
    bool res = false;
    for(int i = x; i <= y - 1; i++) {
        if(S[i] == '#' && S[i + 1] == '#') res = true;
    }
    return res;
}
bool norock3(int x, int y){
    if(x + 1 >= y) return false;
    bool res = false;
    for(int i = x; i <= y - 2; i++) {
        if(S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') res = true;
    }
    return res;
 }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  A --; B --; C --; D --;
   rep(i, N) cin >> S[i]; 
  if( C < D) {
     if((!(rock2(A + 1, C - 1))) && (!(rock2(B + 1, D - 1)))) {
         cout << "Yes" << endl; return 0;
     }
     else {
         cout << "No" <<endl; return 0;
     }
  }
  else {
     if((!(rock2(A + 1, C - 1))) && (!(rock2(B + 1, D - 1)))) {
         if(norock3(B - 1, D + 1)) Yes();
         else No();
     }
     else No();
  }
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
    long long  n,sum=0;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0){
            continue;
        }
        sum+=i;
    }
    printf("%lld\n",sum);
    return 0;
}

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

int main()
{
  for( ; ; ) {
    int a, b ;
    std::string op ;

    std::cin >> a >> op >> b ;

    if ( op == "+" )
      std::cout << a + b << std::endl ;
    else if ( op == "-" )
      std::cout << a - b << std::endl ;
    else if ( op == "*" )
      std::cout << a * b << std::endl ;
    else if ( op == "/" )
      std::cout << a / b << std::endl ;
    else if ( op == "?" )
      return 0 ;
  }

  return 0 ;
}

Measured memory_bytes: 3128
#include <stdio.h>
typedef struct node{
  int p,lc,rb;
  
} node;

node tree[100000];

int getdepth(int x){
  if(tree[x].p==-1){
    return 0;
  } else{
    return getdepth(tree[x].p)+1;
  }
}

int main(){

 
  int n,d,d2,k,l,id;
  int i,j;

  for(i=0;i<100000;i++){
    tree[i].p=-1;
    tree[i].lc=-1;
    tree[i].rb=-1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      d2=d;
      scanf("%d",&d);
      tree[d].p=id;
      if(j==0){
	tree[id].lc=d;
      }else{
	tree[d2].rb=d;
      }

    }
    
  }


  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].p,getdepth(i));
    if(tree[i].p==-1){
      printf("root, ");
    } else if(tree[i].lc==-1){
      printf("leaf, ");
    } else {
      printf("internal node, ");
    }
    printf("[");
    if(tree[i].lc!=-1){
      printf("%d",tree[i].lc);
      j=tree[i].lc;
      while(1){
	j=tree[j].rb;
	if(j==-1)break;
	printf(", %d",j);
      }
    }
    printf("]\n");
  }
  


  return 0;
}

Measured memory_bytes: 1788
// #define __LOCAL_DEBUG__
#include<bits/stdc++.h>
using namespace std;
#ifdef __LOCAL_DEBUG__
# define _debug(x) { cerr << "\033[94m" << __func__ << " " << #x << ": " << (x) << "\n\033[0m"; }
#else
# define _debug(x) {((void) 0);}
#endif
#define REP(i, n) for (int i = (0); i < (n); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define EACH(x, arr) for (auto& x : arr) 
#define ITR(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define CLR(x, v) memset(x, v, sizeof (x))
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
using ll = signed long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 700;

int n;
void MAIN() {
    cin >> n;
    VI c(n);
    REP(i, n) cin >> c[i];
    int t = 0;
    REP(i, n) if (i == 0 || c[i] != c[i - 1]) c[t++] = c[i];
    n = t;
    VI pre(2e5 + 10, -1);
    VI go(2e5 + 10);
    REP(i, n) go[i] = pre[c[i]], pre[c[i]] = i;
    VI dp(n);
    dp[0] = 1;
    REP(i, n) {
        _debug(c[i]);
        _debug(go[i]);
    }
    REPP(i, 1, n) {
        if (go[i] == -1) dp[i] = dp[i - 1];
        else {
            _debug(go[i])
            dp[i] = (dp[i - 1] + dp[go[i]]) % MOD;
        }
        _debug(dp[i])
    }
    cout << dp[n - 1] << endl;
} 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int TC = 1;
    // cin >> TC;
    REP(tc, TC) {
    // while (cin >> n, n) {
        // cout << "Case " << tc + 1 << ": ";
        MAIN();
    }
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
ll a[200][200];
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max(c-a+b,0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
int x,y;
typedef pair<int,int> pii;
#define fi first
#define se second
multiset<pii> ms;
for(int i=0;i<n;i++) { cin>>x>>y; ms.emplace(x,y); }
set<int> s1,s2;
int ans=0; 
for(auto& i:ms){
if(!s1.empty()){ int cv1=i.fi+i.se,cv2=i.fi-i.se; ans=max(ans,max(cv1-*s1.begin(),cv2-*s2.begin()));  }
s1.emplace(i.fi+i.se); s2.emplace(i.fi-i.se);
}
cout<<ans<<'\n'; 
return 0;
}

Measured memory_bytes: 31684
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
using namespace std;

void solve()
{
    char s[4];
    cin >> s;
    int i=0,cnt=0,p;
    for(i=0;i<3;i++)
    {
        p=0;
        while(s[i]=='R')
        {
            p++;i++;
        }
        cnt=max(cnt,p);
    }
    cout << cnt << endl;
}

int main()
{
    int t=1;
    //cin >> t;
    while(t--)
    solve();

    return 0;
}




Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if (N==M) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 25172
#include <stdio.h>
#define MAX 100000
int main(void)
{
    int n;
    int i;
    int x;
    int a;
    int cnt[MAX + 2];
    int max;

    scanf("%d", &n);
    for (x = 0; x < MAX + 2; x++) {
        cnt[x] = 0;
    }
    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        cnt[a]++;
        cnt[a + 1]++;
        cnt[a + 2]++;
    }
    max = 0;
    for (x = 0; x < MAX + 2; x++) {
        if (max < cnt[x]) {
            max = cnt[x];
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  char c;
  scanf("%c", &c);
  switch(c){
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
      printf("vowel\n");
      break;
    default:
      printf("consonant\n");
      break;
  }
}


Measured memory_bytes: 128
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define N 100005
#define mod 1000000007


int main()
{   
    string s;cin>>s;
    ll n=s.size();
    ll cnt=0;
    for(ll i=1;i<n-1;i++)
    {
        if(s[i]==s[i-1] && s[i]==s[i+1])
        {
            if(s[i]=='0')
            s[i]='1';
            else
            s[i]='0';
            cnt+=1;
        }
        else if(s[i]==s[i-1] && s[i]!=s[i+1])
        {
            if(s[i]=='1')
            s[i]='0';
            else
            s[i]='1';
            cnt+=1;
        }
    }
    for(ll i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
        cnt+=1;
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3724