akhauriyash/Code-Regression huggingface dataset:
class Dice(object):
    """
    6??¢???????????????
    ?????¢???top, ?????¢???bottom???????????\??????4??¢??????????????? north, south, east, west ??¨?????¶???
    """
    def __init__(self, faces):
        # faces???????????????????????¨?????????????????????????????????
        # ???????????? top, south, east, west, north, bottom ????????§????´????????????????????????¨??????????????????????????§???top??????????????£????????????
        self.top = faces[0]
        self.south = faces[1]
        self.east = faces[2]
        self.west = faces[3]
        self.north = faces[4]
        self.bottom = faces[5]

    def rotate(self, dir):
        # ???????????????dir??????????????????????????¢?????????
        # ????????????N, S, E, W???????????????????????????(1??????)??§????????????
        if dir == 'N':
            temp = self.top
            self.top = self.south
            self.south = self.bottom
            self.bottom = self.north
            self.north = temp
        elif dir == 'S':
            temp = self.top
            self.top = self.north
            self.north = self.bottom
            self.bottom = self.south
            self.south = temp
        elif dir == 'E':
            temp = self.top
            self.top = self.west
            self.west = self.bottom
            self.bottom = self.east
            self.east = temp
        elif dir == 'W':
            temp = self.top
            self.top = self.east
            self.east = self.bottom
            self.bottom = self.west
            self.west = temp
        # self.print()

    def get_top_value(self):
        return self.top

    def print(self):
        print('=' * 64)
        print('top: {0}'.format(self.top))
        print('south: {0}'.format(self.south))
        print('bottom: {0}'.format(self.bottom))
        print('north: {0}'.format(self.north))
        print('east: {0}'.format(self.east))
        print('west: {0}'.format(self.west))
        print('=' * 64)


if __name__ == '__main__':
    # ??????????????\???
    dice_values = [int(x) for x in input().split(' ')]
    rotations = input()

    # ????????????????????????????????¢?????????
    d = Dice(dice_values)
    for r in rotations:
        d.rotate(r)

    # ?????¢??????????¢????????????????
    print('{0}'.format(d.get_top_value()))

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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;

ll pwr(ll a, ll n){
	if(n==0) return 1;
	ll q = pwr(a,n / 2);
	q = q * q % mod;
	if(n&1) 
		q = q * a % mod;
	return q;
}

void solve(){
	int n,k;
	cin >> n >> k;
	ll res = 0;
	vector<ll> cnt(k+1);
	for(int i = k; i >= 1; i--){
		cnt[i] = pwr(k / i,n);
		for(int j = 2 * i; j <= k; j+=i){
			cnt[i] -= cnt[j];
			cnt[i]%=mod;
		}
		res = (res + i * cnt[i]) % mod;
	}
	cout << (res + mod)%mod << "\n";
}
int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

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

typedef long long ll;
typedef long double ld;

using namespace std;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	INeedIt();
	string s;
	cin>>s;
	for (int i=0;i<s.size();i+=2) {
		if (s[i]=='L') {
			cout<<"No";
			return 0;
		}
	} 
	for (int i=1;i<s.size();i+=2) {
		if (s[i]=='R') {
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 892
import collections

h,w = map(int,input().split())
field = [["#"] + list(str(input())) + ["#"] for i in range(h)]

field.append(["#"]*(w+2))
field.insert(0,["#"]*(w+2))

dx = [1,0,-1,0]
dy = [0,1,0,-1]

def f():
    global ans
    s = q.popleft()
    y,x = s[0],s[1]
    for i in range(4):
        newy = y+dy[i]
        newx = x+dx[i]
        if field[newy][newx] == "." and memo[newy][newx] == "#": 
            q.append((newy,newx))
            memo[newy][newx] = memo[y][x] + 1
            ans = max(ans,memo[y][x] + 1)

ans = 0
for i in range(1,h+1):
    for j in range(1,w+1):
        if field[i][j] == "#":
            continue
        q = collections.deque()
        q.append((i,j))
        memo = [["#"]*(w+2) for i in range(h+2)]
        memo[i][j] = 0
        while q:
            f()

print(ans)


Measured memory_bytes: 9432
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    string S;
    cin >> S;
    int N = int(S.length());
    
    S+="2";
    
    char fnow = S[0];
    int leak = 0;
    int left = 0;
    ve<pii> A;
    rep(i,N+1){
        if(fnow == S[i]){
            leak++;
        }else{
            A.pb({left,leak});
            left += leak;
            leak = 1;
            fnow = S[i];
        }
    }
    
    int n = int(A.size());
    
    int ans = infi;
    int an = infi;
    for (int i = 0; i < n; i+=2) {
        int a = min(A[i].fi+A[i].se,N-A[i].fi);
        int b = max(A[i].fi,N-A[i].se-A[i].fi);
        an = min(an,max(a,b));
    }
    ans = an;
    for (int i = 1; i < n; i+=2) {
        int a = min(A[i].fi+A[i].se,N-A[i].fi);
        int b = max(A[i].fi,N-A[i].se-A[i].fi);
        an = min(an,max(a,b));
    }
    ans = max(ans,an);
    
    out(ans);
    
    
    

    return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B){
        if(A != C){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(B == C){
        if(A != B){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(C == A){
        if(C != B){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

if N == M//2:
    print(N)

elif N > M//2:
    # print(M//2 + (N - M//2)//2)
    print(M//2)

else:
    print(N + (M - N*2 )//4)


Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>


int main(){
	int N;
	scanf("%d",&N);
	int cand = (int)N/1.08;
	int val_cand = int(cand*1.08);
	if (val_cand==N){
		printf("%d\n", cand);
		return 0;
	}
	if (val_cand>N){
		while(val_cand>N){
			cand--;
			val_cand=int(cand*1.08);
			if (val_cand==N){
				printf("%d\n", cand);
				return 0;
			}
		}
	}
	else {
		while (val_cand<N){
			cand++;
			val_cand=int(cand*1.08);
			if (val_cand==N){
				printf("%d\n",cand);
				return 0;
			}
		}
	}
	printf(":(\n");
	return 0;
}

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

int main(){
	int x, y;
	
	while(1){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}
		if(x < y){
			cout << x << " " << y << endl;
		}else{
			cout << y << " " << x << endl;
		}
	}
		return 0;
}

Measured memory_bytes: 3064
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

vector<pii> g[100001];
int c[100001];

void dfs(int p, int bef, int x){
    c[p] = x;
    for(pii P : g[p]){
        if(P.first != bef){
            int to = P.first;
            int w= P.second;
            dfs(to,p,x ^ (w%2));
        }
    }
}

int main(){
    int n;
    cin >> n;
    REP(i, n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        g[u].push_back(pii(v,w));
        g[v].push_back(pii(u,w));
    }
    dfs(0,-1,0);
    REP(i,n)cout<<c[i]<<endl;
    return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=22e4,M=N<<1;

int le[M],ri[M],g[M],a[N];
int n;

int main()
{
	scanf("%d",&n);
	fo(i,1,n)scanf("%d",&a[i]);
	int l=0,r=n;
	while(l+1<r){
		int mid=l+r>>1;
		int s=1,ok=1;
		le[1]=1,ri[1]=a[1]; g[1]=1;
		fo(i,2,n)if(a[i]>a[i-1]){
			le[++s]=ri[s-1]+1;
			ri[s]=a[i];
			g[s]=1;
		}else{
			while(le[s]>a[i])--s;
			ri[s]=a[i];
			if(g[s]==mid){
				int u=s;
				while(g[s]==mid){
					g[s]=1;
					--s;
				}
				if(s==0){
					ok=0; break;
				}else {
					if(le[s]==ri[s])++g[s];
					else{	
						le[++s]=ri[s-1];
						--ri[s-1];
						ri[s]=le[s];
						g[s]=g[s-1]+1;
					}
					le[++s]=ri[s-1]+1;
					ri[s]=a[i];
					g[s]=1;
				}
			}else{
				if(le[s]==ri[s])++g[s];
				else{
					le[++s]=ri[s-1];
					--ri[s-1];
					ri[s]=le[s];
					g[s]=g[s-1]+1;
				}
			}
		}
		if(ok)r=mid;
		else l=mid;
	}
	cout<<r;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

const ll mod = 1e9+7;
const int N = 2000000;
ll fac[N+1], ifac[N+1];

ll Pow(ll a, ll b)
{
	ll x = 1;
	for (; b > 0; b >>= 1)
	{
		if (b & 1) x = x * a % mod;
		a = a * a % mod;
	}
	return x;
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= N; ++i)
	{
		fac[i] = fac[i-1] * i % mod;
		ifac[i] = Pow(fac[i], mod-2);
	}

	int x, y;
	cin >> x >> y;

	int ans = 0;
	for (int i = 1; i <= min(x, y); ++i)
	{
		int l = x-i, r = y-i;
		if (l+r == i)
			ans = (ans + fac[l+r] * ifac[l] % mod * ifac[r] % mod) % mod;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

LL fact[1145141];
LL revf[1145141];

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res =res*base% MOD;
  return res;
}

LL Comb(int N, int K) {
  if (N < K || K < 0) return 0;
  LL ret = fact[N] * revf[K] % MOD;
  return ret*revf[N-K] % MOD;
}

int N;
char buf[1145141];
int cnt[30];

int main() {
  scanf("%d", &N);
  scanf(" %s", buf);

  fact[0] = revf[0] = 1;
  reps(i, 1, N+10) {
    fact[i] = fact[i-1] * i % MOD;
    revf[i] = revf[i-1] * mypow(i, MOD-2) % MOD;
  }

  rep(i, N) {
    cnt[buf[i]-'a']++;
  }

  LL ans = 1;
  rep(i, 26) {
    ans = ans*(cnt[i]+1)%MOD;
    //cout << cnt[i] << endl;
    //cout << ans << endl;
    //Comb(cnt[i], 1)%MOD; 
  }
  ans--;
  printf("%lld\n", ans);
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=5e5+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      string s;
      cin>>s;
      int a=(s[0]-'0')*10+s[1]-'0';
      int b=(s[2]-'0')*10+s[3]-'0';
      if((a>12||a==0)&&b<=12&&b>=1)
      {
            cout<<"YYMM";
      }
      else if((a<=12)&&(b>12||(b==0))&&a>=1)
      {
            cout<<"MMYY";
      }
      else if(a<=12&&b<=12&&b>=1&&a>=1) cout<<"AMBIGUOUS";
      else cout<<"NA";
}     



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int> oks(n+1,true);
    REP(i,m){
        int a;cin>>a;
        oks[a]=false;
    }
    vector<ll> dp(n+1);
    dp[0]=1;
    for(int i;i<=n;i++){
        for(int next=i+1;next<=min(n,i+2);next++){
            if(oks[next]){
                dp[next]+=dp[i];
                dp[next]%=MOD;
            }
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int gcd(int a,int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
ll ceil(ll a,ll b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int n,m,i,j,x,y;
    cin>>n>>m;
    int arr[n+1];
    vector<int> adj[n+1];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        if(arr[x-1]>=arr[y-1])
        {
            adj[y].push_back(x);
        }
        if(arr[x-1]<=arr[y-1])
        {
            adj[x].push_back(y);
        }
        
    }
    int cnt=0;
    for(i=1;i<=n;i++)
    {
        //cout<<adj[i].size()<<endl;
        if(adj[i].size()==0)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 8748
n = int(input())
p = list(map(float , input().split()))

dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(n):
        dp[i + 1][j + 1] += dp[i][j] * p[i]
        dp[i + 1][j] += dp[i][j] * (1 - p[i])

ans=0
for i in range(n // 2 + 1, n + 1):
    ans += dp[n][i]
print(ans)

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

int main(){
  int s; cin >> s;
  vector<int> H(1); H[0] = s;
  bool doubled; doubled = true;
  int ans, elements, f_element, n_element;
  while(doubled){
    elements = H.size();
    f_element = H[elements-1];
    if(f_element % 2 == 0){
      n_element = f_element / 2;
    }else{
      n_element = 3 * f_element + 1;
    }for(int i = 0; i < elements; i++){
      if(H[i] == n_element){
        doubled = false;
        ans = elements + 1;
      }
    }
    H.push_back(n_element);
  }
  cout << ans << endl;
}

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

int INF = 1e9;

int main() {
  int N;
  cin >> N;
  vector<int> minChar(256, INF);
  vector<int> dp(N);
  rep(i, N) {
    string w;
    cin >> w;
    if (i == 0) {
      dp[i] = 1;
    } else {
      dp[i] = min(dp[i - 1] + 1, minChar[w[0]]);
    }
    minChar[w[0]] = min(minChar[w[0]], dp[i]);
  }
  cout << dp[N - 1] << endl;
}



Measured memory_bytes: 3444
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::vector<i64> result(N);
  for (i64 i = 0; i < N; ++i) {
    result[A[i] - 1] = i + 1;
  }

  {
    std::string delimiter = "";
    for (const i64& result_i : result) {
      std::cout << delimiter << result_i;
      delimiter = " ";
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a, b, c;
	//string s="error";
	cin >> a; cin >> b; cin >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i,N) cin >> S[i];
    vector<pair<int, int>> posi, nega;

    int sum = 0;
    REP(i,N){
        int cnt = 0;
        int mi = 0;
        REP(j,S[i].size()){
            if(S[i][j] == '(') cnt++;
            else cnt--;
            chmin(mi, cnt);
        }
        if(cnt > 0) posi.emplace_back(mi, cnt);
        else nega.emplace_back(mi - cnt, -cnt);
        sum += cnt;
    }
    if(sum != 0){
        cout << "No" << endl;
        return;
    }
    sort(posi.rbegin(), posi.rend());
    sort(nega.rbegin(), nega.rend());
    int cur = 0;
    for(auto [mi, cnt] : posi){
        // cout << mi << " " << cnt << endl;
        if(cur + mi < 0){
            cout << "No" << endl;
            return;
        }
        cur += cnt;
    }
    cur = 0;
    for(auto [mi, cnt] : nega){
        // cout << mi << " " << cnt << endl;
        if(cur + mi < 0){
            cout << "No" << endl;
            return;
        }
        cur += cnt;
    }
    cout << "Yes" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 42544
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3776");
            //Bad
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8080");
            //Good
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1333");
            //Bad
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("0024");
            //Bad
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        int UB = S.Length - 1;
        bool IsBad = false;
        for (int I = 0; I <= UB - 1; I++) {
            if (S[I] == S[I + 1]) {
                IsBad = true;
            }
        }
        Console.WriteLine(IsBad ? "Bad" : "Good");
    }
}


Measured memory_bytes: 11092
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let ps = scan!(f64;;);

    let mut dp = vec![vec![0.0f64; n + 1]; n + 1];
    dp[0][0] = 1.0;
    for i in 0..ps.len() {
        dp[i + 1][0] = dp[i][0] * (1.0 - ps[i]);
        for j in 1..i + 2 {
            dp[i + 1][j] += dp[i][j - 1] * ps[i] + dp[i][j] * (1.0 - ps[i])
        }
    }
    println!("{}", dp[n].iter().rev().take((n + 1) / 2).sum::<f64>())
}


Measured memory_bytes: 90364
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin >> x;
    ll gcd = __gcd(x, (ll)360);
    ll lcm = (x * 360) / gcd;
    cout << (lcm / x) << "\n";
}

Measured memory_bytes: 3608
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
a = LIST()

all_xor = a[0]
for x in a[1:]:
	all_xor ^= x

for x in a:
	print(all_xor^x, end=" ")
print()


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

int main(){
    
    string S;
    cin>>S;
    int N=S.length();
    int cnt=0;
    if(N%2==0){
        for(int i=0;i<N/2;i++){
            if(S[i]=='p') cnt--;
        }
        for(int i=N/2;i<N;i++){
            if(S[i]=='g') cnt++;
        }
    }else{
        for(int i=0;i<N/2+1;i++){
            if(S[i]=='p') cnt--;
        }
        for(int i=N/2+1;i<N;i++){
            if(S[i]=='g') cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 512
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.math.BigDecimal;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int P = in.nextInt();
            int A[] = new int[N];
            int even = 0;
            int odd = 0;
            long res = 1;

            long[][] C = new long[100 + 1][100 + 1];
            for (int i = 0; i <= 100; i++) {
                C[i][0] = 1;
                for (int j = 1; j <= i; j++) {
                    C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
                }
            }
            for(int i=0; i<N; i++){
                A[i] = in.nextInt();
                if(A[i]%2==0){
                    even++;
                    res *= 2;
                }
                else odd++;
            }
            long a=0;
            if(P==0){
                for(int i=0; 2*i<=odd; i++){
                    a += C[odd][2*i];   
                }
            }
            else{
                for(int i=1; 2*i-1<=odd; i++){
                    a += C[odd][2*i-1];   
                }
            }
            out.println(res*a);
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 23380
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    deque<pair<string, int>> ps;
    for (int i = 0; i < n; i++) {
        string name;
        int time;
        cin >> name >> time;
        ps.push_back(make_pair(name, time));
    }

    int t = 0;
    while (!ps.empty()) {
        auto p = ps.front();
        ps.pop_front();
        int use = min(q, p.second);
        t += use;
        p.second -= use;
        if (p.second > 0) {
            ps.push_back(p);
        } else {
            cout << p.first << " " << t << endl;
        }
    }
}

Measured memory_bytes: 4404
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll n,k; cin >> n >> k;

	vector<ll> a(n); 
	int digit = (int)ceil(log2(k));
	rep(i,n)  { cin >> a[i]; chmax(digit, (int) ceil(log2(a[i]))); }

	vector<int> cnt(digit);
	rep(i,digit) { 
	  int c = 0;
	  rep(j, n) c += (a[j] >> i & 1);
	  cnt[i] = c;
	}

	bitset<40> ans;
	bool isLower = false;
	rrep(i, digit) {
		if (cnt[i]*2LL <= n && (isLower || k >> i & 1)) ans.set(i);
		else if (k >> i & 1) isLower = true;
	}

	ll sum = 0;
	rep(i, n) {
		sum += a[i] ^ (ll) ans.to_ulong();
	}

	cout << sum << endl;
}

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

int main(){

    int N;
    int i,j,k;
    int l,r;
    int count=0;

    cin >> N;

    for(i=0;i<N;i++){
        cin >> l >> r;
        count += r - l + 1;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int N,A[100000];
  long i,j;
  long S=0,ans;
  long long sum[200000];
  for(i=0;i<200000;i++)sum[i]=0;
  cin >> N;
  for(i=0;i<N;i++)cin >> A[i];
  for(i=0;i<2*N;i++) {
    sum[i+1] = sum[i] + A[(2*i+1)%N];
  }
  S = sum[N] / 2;
  for(i=0;i<N;i++) {
    ans = S - sum[i*(N/2+1)%N+N/2] + sum[i*(N/2+1)%N];
    cout << ans*2 << endl;
  }
}


Measured memory_bytes: 3328
N,W = map(int, input().split())
dp = [0]*(W+1)
temp = [0]*(W+1)

for i in range(1,N+1):
    v,w = map(int,input().split())
    for j in range(w, W+1):
        x = v+temp[j-w]
        if x > temp[j]: dp[j] = x

    temp[0:W+1] = dp[0:W+1]

print(dp[W])

Measured memory_bytes: 6664
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <list>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1e6;
const ll LINF = (ll)1e19;

int main() { 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;
    string prev = "";
    string tmp = "";
    cin >> S;
    int cnt = 0;
    while(S.size() != 0){
        tmp += S.substr(0,1);
        S = S.substr(1,S.size()-1);
        if(prev != tmp){
            prev = tmp;
            tmp = "";
            cnt++;
            //cout << prev << endl;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
    int n;cin>>n;
    int a[n];for(int i=0;i<n;i++)cin>>a[i];
    ll d[n+1];
    for(int i=0;i<=n;i++)d[i]=0;
    d[0]=a[0];
    ll sum=0;
    for(int i=1;i<n;i++){
        if(a[i]<d[i-1]) d[i]=d[i-1];
        else d[i]=a[i];
        sum+=d[i]-a[i];
    }
    cout <<sum;
    
}

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

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

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  char a, b;
  cin >> a >> b;
  if(a=='H')
    if(b=='H') print('H');
    else print('D');
  else
    if(b=='H') print('D');
    else print('H');
  return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    ks = []
    for _ in range(m):
        ks.append(list(map(int, input().split())))
    p = list(map(int, input().split()))

    ans = 0
    for i in range(2**n):
        ls = [0]*m
        for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
        cnt = 0
        for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
        if cnt == m:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		
		System.out.println(Pattern.compile("[A-Z]").matcher(c).matches() ? "A":"a");
	}
}


Measured memory_bytes: 35708
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  int V[N];
  for(int i=0;i<N;++i) cin>>V[i];
  int ans = 0;
  int tmp;
  for(int i=0;i<=N;++i) {
    for(int j=0;i+j<=K && i+j<=N;++j) {
      vector<int> arr;
      for(int k=0;k<i;++k) {
        arr.push_back(V[k]);
      }
      for(int k=0;k<j;++k) {
        arr.push_back(V[N-1-k]);
      }
      sort(arr.begin(), arr.end());
      tmp = 0;
      for(int k=0;k<arr.size();++k) {
        if(k<K-(i+j) && arr[k]<0) continue;
        tmp += arr[k];
      }
      ans = max(ans, tmp);
    }
  }
  cout<<ans<<endl;
}



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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (auto&& e : p) cin >> e;
  sort(begin(p), end(p));
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n,m,x;
long long y;
pair<int,int> a[123456];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
	sort(a,a+n);
	int j=0;
	while(x<m){
		if(a[j].second>0){
			y+=a[j].first;
			a[j].second--;
			x++;
		}
		else{
			j++;
		}
	}
	cout<<y<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>
struct Record {
	int id, reach_time, speed;
	Record turn(const int time) const { return { id, time + speed, speed }; }
};
int main() {
	while (true) {
		int n; std::cin >> n; if (n == 0) return 0;
		std::vector<int> time(n); std::vector<int> target(n);
		for (auto i = 0; i < n; ++i) std::cin >> time[i] >> target[i];
		std::queue<Record> forward, backward;
		auto compare_by_speed = [](const Record& a, const Record& b) {return a.speed > b.speed; };
		std::priority_queue<Record, std::vector<Record>, decltype(compare_by_speed)> queue(compare_by_speed);
		for (auto i = 0; i < n; ++i) {
			queue.push(Record{ i, time[i], time[i] });
		}
		for (auto i = 0; i < n; ++i) {
			forward.push(queue.top()); queue.pop();
		}
		auto last_time = 0; auto end_count = 0;
		while (end_count != n) {
			while (!forward.empty() && (backward.empty() || backward.front().reach_time >= forward.front().reach_time)) {
				last_time = forward.front().reach_time;
				while (!forward.empty() && forward.front().reach_time <= last_time) {
					queue.push(forward.front()); forward.pop();
				}
				while (!queue.empty()) {
					backward.push(queue.top().turn(last_time)); queue.pop();
				}
			}
			while (!backward.empty() && (forward.empty() || forward.front().reach_time >= backward.front().reach_time)) {
				last_time = backward.front().reach_time;
				while (!backward.empty() && backward.front().reach_time <= last_time) {
					--target[backward.front().id];
					if (target[backward.front().id] != 0) {
						queue.push(backward.front());
					}
					else {
						++end_count;
					}
					backward.pop();
				}
				while (!queue.empty()) {
					forward.push(queue.top().turn(last_time)); queue.pop();
				}
			}
		}
		std::cout << last_time << std::endl;
	}
}


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

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

  vector<char> vec_s(s.size());
  vector<char> vec_t(t.size());

  rep(i, 0, s.size()) {
    vec_s.at(i) = s[i];
  }
  rep(i, 0, t.size()) {
    vec_t.at(i) = t[i];
  }

  sort(vec_s.begin(), vec_s.end());
  sort(vec_t.begin(), vec_t.end(), greater<char>());

  rep(i, 0, s.size()) {
    s[i] = vec_s.at(i);
  }
  rep(i, 0, t.size()) {
    t[i] = vec_t.at(i);
  }

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

const int MAX = 1001;
typedef pair<int,int> P;

int main(){
    int n,m,h,r;
    
    while(cin >> n ,n){
        vector<P> v;
        int dp[MAX] = {0};
        
        for(int i = 0 ; i < n ; i++){
            cin >> h >> r;
            v.push_back(P(h,r));
        }
        
        cin >> m;
        for(int i = 0 ; i < m ; i++){
            cin >> h >> r;
            v.push_back(P(h,r));
        }
        
        sort(v.begin(),v.end());
        
        int res = 0;
        for(int i = 0 ; i < n+m ; i++){
            dp[i] = 1;
            for(int j = 0 ; j < i ; j++){
                if(v[j].first < v[i].first && v[j].second < v[i].second){
                    dp[i] = max(dp[i],dp[j]+1);
                }
                res = max(res,dp[i]);
            }
        }
        cout << res << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1204
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf = 1e18;
ll mod=1e9+7;
//LLONG_MIN

/*
*/

ll H,W,h,w;

int main(void){
	cin>>H>>W>>h>>w;
	cout<<(H-h)*(W-w)<<endl;
	return 0;
}

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

using namespace std;

#define LL long long

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

    vector<LL> vt;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mp[a]++;
        if (mp[a] == 2) { // 4本ある棒は2本x2として2回追加する
            vt.push_back(a);
            mp[a] = 0;
        }
    }

    sort(vt.begin(), vt.end(), greater<>());
    LL ans = 0;
    if (vt.size() >= 2) {
        ans = vt[0] * vt[1];
    }

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


Measured memory_bytes: 4992
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << ((a+b+c) >= 22 ? "bust" : "win") << endl;
}


Measured memory_bytes: 256