akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,ans=1145141919;
string s;
bool Main(){
    cin>>n>>s;
    vector<ll> west(n+1),east(n+1);
    west.at(0)=0;
    east.at(0)=0;
    For(i,0,n){
        west.at(i+1)=west.at(i);
        east.at(i+1)=east.at(i);
        if(s.at(i)=='W') west.at(i+1)++;
        if(s.at(n-1-i)=='E') east.at(i+1)++;
    }
    For(i,0,n){
        ans=min(ans,west.at(i)+east.at(n-1-i));
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 5380
using System;
using System.Linq;

namespace Test04
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string nums = Console.ReadLine();
			string orders = Console.ReadLine();
			char[] ordersArray = orders.ToCharArray();
			int[] numsArray= nums.Split(' ').Select(x => int.Parse(x)).ToArray();
			int[] diceArray = new int[6];
			DiceClass dice = new DiceClass();
			for (int i = 0; i < ordersArray.Length; i++)
			{
				dice.DiceArray(numsArray, ordersArray[i], diceArray);
				for (int j = 0; j < numsArray.Length; j++)
				{
					numsArray[j] = diceArray[j];
				}

			}
			Console.WriteLine(diceArray[0]);
		}
	}

	class DiceClass
	{
		public void DiceArray(int [] a,char b,int[] c)
		{
			if (a.Length > 0 && c.Length > 0)
			{
				if (b == 'E')
				{
					c[0] = a[3];
					c[1] = a[1];
					c[2] = a[0];
					c[3] = a[5];
					c[4] = a[4];
					c[5] = a[2];
				}
				else if (b == 'S')
				{
					c[0] = a[4];
					c[1] = a[0];
					c[2] = a[2];
					c[3] = a[3];
					c[4] = a[5];
					c[5] = a[1];
				}
				else if (b == 'W')
				{
					c[0] = a[2];
					c[1] = a[1];
					c[2] = a[5];
					c[3] = a[0];
					c[4] = a[4];
					c[5] = a[3];
				}
				else if (b == 'N')
				{
					c[0] = a[1];
					c[1] = a[5];
					c[2] = a[2];
					c[3] = a[3];
					c[4] = a[0];
					c[5] = a[4];
				}
			}
		}
	}
}

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff         first
  #define  ss         second
  #define  pb         push_back
  #define  all(x)     (x).begin(), (x).end()
  #define  rep(i,a,b) for(ll i=a ; i<b ; ++i)
  #define  D(x)       cout << #x << " - " << x << endl;
  #define  IOS        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D2(x)      cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  D2p(x)      cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)    fixed<<setprecision(y)<<x

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll MAX_N = 1e6+4;
  void solve(){
     int n;
     cin >> n;
     int cnt=0;
     for(int i=1;i<=n;i++){
       int a;
       cin >> a;
       if(i%2 && a%2)cnt++;
     }
     cout << cnt;

  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3784
#include<stdio.h>
int main(){
  int N;
  int s;
  scanf("%d",&N);
  int arr[200010]={0};
  int arr1[200010]={0};
  for(int i=0;i<(N-1);i++)
  {
    scanf("%d",&arr[i]);
  }
  for(int i=0;i<(N-1);i++){
    s=arr[i];
    arr1[s-1]=arr1[s-1]+1;
  }
for(int i=0; i<N;i++){
  printf("%d\n",arr1[i]);
}
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

signed main(){
	int n=read();
	assert(1<=n&&n<=100000);
	vi c(n,0);
	REP(i,n){
		int a=read();
		assert(0<=a&&a<=n-1);
		c[a]++;
	}
	int ans=1;
	const int mod=1000000007;
	REP(i,n){
		if(i%2==(n-1)%2){
			if(i==0){
				if(c[i]!=1)
					ans=0;
			}else{
				if(c[i]!=2)
					ans=0;
				ans=ans*2%mod;
			}
		}else{
			if(c[i])
				ans=0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
n = int(input())
l = [int(e) for e in input().split()]

l.sort()
count = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if l[i] == l[j]:
            continue
        for k in range(j + 1, n):
            if l[j] == l[k]:
                continue
            if (l[i] + l[j]) > l[k]:
                count += 1
                
print(count)

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
#define N 200093
long long k;
int T,f[N],g[N],u,v,st[N],t,n,a[N],h[N],tt,hh[N];
inline void pr(int u)
{
	while(u<=n){
		if(f[u]>u)u=f[u]; else printf("%d ",a[u]);
		++u;
	}
	exit(0);
} 

int main()
{
	n=read(); cin >> k;
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i) {
		if(!h[a[i]])h[a[i]]=i;
	}
	for(int i=n;i;--i){
		if(!g[a[i]])f[i]=h[a[i]]; else f[i]=g[a[i]];
		g[a[i]]=i;
	}
	
	
	u=1;
	 
	/*
	while(1){
		v=f[u]+1;if(v>n)v=1;
		if(v<=u+1)++T;
		if(v==1)break;
		u=v;
	}
	*/ 
	
	T=1;
	while(1){
		if(f[u]<=u)++T;
		v=f[u]+1; 
		if(v==n+1)break;
		u=v;
	}
	
	u=1; --k; k%=T; if(!k)pr(u);
	while(1){
		v=f[u]+1;if(v>n)v=1;
		if(v<=u+1)--k;
		if(!k)pr(v);
		u=v;
	}
}

Measured memory_bytes: 5376
from collections import defaultdict


def get_cnt(n_dic, stop):
    cnt = 0
    for i, item in enumerate(sorted(n_dic.items(), key=lambda x: x[1])):
        cnt += item[1]
        if i+1 == stop:
            break
    return cnt


def main():
    n, k = map(int, input().split())

    n_dic = defaultdict(lambda: 0)
    for x in input().split():
        n_dic[int(x)] += 1

    stop = len(n_dic) - k
    if stop > 0:
        cnt = get_cnt(n_dic, stop)
    else:
        cnt = 0
    print(cnt)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 41492
N = int(input())
H = list(map(int,input().split()))
H.append(0)

cnt = 0
stop = max(H)
while stop>0:
    stop += -1
    for i in range(N):
        if H[i]>0 and H[i+1]==0:
            cnt+=1
    for i in range(N):
        if H[i]>0:
            H[i]+=-1
print(cnt)


Measured memory_bytes: 67116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

vector <ll> factorials;
vector <ll> inv_factorials;
ll mod=1e9+7;

ll modExp(ll x, ll n)
{
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}

ll modInv(ll a)
{
    return modExp(a, mod-2);
}

ll choose(ll n, ll k) 
{
    if (k==0) return 1;
    if (k<0 || k>n) return 0;
    ll ans = factorials[n] * inv_factorials[k] % mod;
    return (ans * inv_factorials[n - k]) % mod;
}

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

    const int kRange = 3e6;
    factorials.resize(kRange + 1, 1);
    inv_factorials.resize(kRange + 1, 1);
    loop(i,2, kRange+1)
    {
        factorials[i]=(factorials[i-1]*i)%mod;
    }
    inv_factorials[kRange] = modInv(factorials[kRange]);
    for (int i = kRange - 1; i >= 0; --i) {
        inv_factorials[i] = (inv_factorials[i + 1] * (i + 1)) % mod;
    }

    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans=0;
    for (ll j=c1; j<=c2; ++j)
    {
        ll temp = (choose(r2+j+1, j+1)-choose(r1+j, j+1)+mod)%mod;
        ans = (ans+temp)%mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 47104
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.pb(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}

int main(){
  ll i=11,N,ans=0,x;
  cin>>N;
  ans=N*(N-1)/2;
  cout<<ans<<endl;
  return 0;
  vec v=eratosthenes(55555);
  while(1){
    if(v[i]){
      cout<<i<<" ";
      if(--N==0)return 0;
    }
    i+=5;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef tuple<int, int> state;
vector<state> ans;

int main () {
  int N;
  cin >> N;
  int a[100];
  for (auto i = 0; i < N; ++i) {
    cin >> a[i];
  }
  bool isplus = true;
  int b = 0;
  int ind = 0;
  for (auto i = 0; i < N; ++i) {
    if (b < abs(a[i])) {
      b = abs(a[i]);
      ind = i;
      isplus = (a[i] > 0);
    }
  }
  if (b == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (auto i = 0; i < N; ++i) {
    ans.push_back(state(ind, i));
  }
  if (isplus) {
    for (auto i = 0; i < N-1; ++i) {
      ans.push_back(state(i, i+1));
    }
  } else {
    for (auto i = N-1; i > 0; --i) {
      ans.push_back(state(i, i-1));
    }
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << get<0>(x)+1 << " " << get<1>(x)+1 << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int counter = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == counter + 1) counter++;
		}

		if (counter == 0 && a[0] != 1) {
			System.out.println(-1);
			return;
		}

		System.out.println(n - counter);
	}
}


Measured memory_bytes: 75540
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

signed main() {
    int N; scanf("%lld", &N);
    vector<int> a(N), b(N);
    for(int i=0; i<N; i++) {
        scanf("%lld", &a[i]);
    }
    for(int i=0; i<N; i++) {
        scanf("%lld", &b[i]);
    }

    int ans = 0;
    for(int k=28; k>=0; k--) {
        int i1 = 0, i2 = 0, i3 = 0;
        int T = 1 << k, ad = 0;
        for(int i=0; i<N; i++) {
            a[i] %= 2*T, b[i] %= 2*T;
        }
        sort(a.begin(), a.end(), greater<int>());
        sort(b.begin(), b.end());
        for(int i=0; i<N; i++) {
            while(i1 < N && a[i] + b[i1] <   T) i1++;
            while(i2 < N && a[i] + b[i2] < 2*T) i2++;
            while(i3 < N && a[i] + b[i3] < 3*T) i3++;
            ad += (i2 - i1) + (N - i3);
        }
        if(ad % 2) ans += T;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main()
{
	int n, a[3][101];

	cin >> n;

	for (int i = 1; i <= 2; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}

	int sum = 0, max = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (j < i)
			{
				sum += a[1][j];
			}
			else if(j > i)
			{
				sum += a[2][j];
			}
			else
			{
				sum += a[1][j] + a[2][j];
			}

		}

		if (sum > max) max = sum;
		sum = 0;
	}


	cout << max << endl;



}

Measured memory_bytes: 256
h, n = map(int, input().split())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

INF = float("inf")
    
dp = [[INF] * (1+10**4) for i in range(1+10**3)]


dp[0][0] = 0

for i in range(n):
    for j in range(h+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][min(h, j+a[i])] = min(dp[i+1][min(h, j+a[i])], dp[i+1][j] + b[i])

print(dp[n][h])


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll C[100005], S[100005], F[100005];
int main()
{
    int N;
    cin >> N;
    REP(i, N - 1)
    {
        cin >> C[i] >> S[i] >> F[i];
    }

    REP(i, N)
    {
        ll t = 0;
        FOR(j, N - 1, i)
        {
            //! 待つ時間
            if (S[j] - t >= 0)
            {
                t += (S[j] - t);
            }
            else
            {
                t += (F[j] - abs(S[j] - t) % F[j]) % F[j];
            }
            t += C[j];
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 768
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long V = sc.nextLong();
		long B = sc.nextLong();
		long W = sc.nextLong();
		long T = sc.nextLong();
		
		long D = Math.abs(B-A);
		long S = V-W;
		
        if(S*T < D) {System.out.println("NO");}
		else {System.out.println("YES");}
	}
}


Measured memory_bytes: 35600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1505,mod=998244353;
int n,cnt,num,e[2],st[N],tot,a[N][N],c[N][N],head[N],nex[N*N<<1],to[N*N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
char s[N][N];
vector<int>v[N][N];
bool vis[N];
void dfs(int u)
{
    vis[u]=true;
    cnt++;num^=st[u];
    for(int i=head[u];i;i=nex[i])
        if(!vis[to[i]])
            dfs(to[i]);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++) scanf("%s",s[i]+1);
    for(int i=0;i<=n;i++)
    {
        int x=i,y=0,dx=1,dy=1;
        for(int j=1;j<=(i==0||i==n?n:2*n);j++)
        {
            v[x][y].push_back(i);
            if(x+dx<0||x+dx>n) dx*=-1;
            if(y+dy<0||y+dy>n) dy*=-1;
            x+=dx;y+=dy;
        }
    }
    for(int i=1;i<n;i++)
        for(int j=1;j<n;j++)
        if(s[i][j]=='o') a[i][j]=2;
        else if(s[i][j]=='x') a[i][j]=1;
    for(int i=1;i<n;i++)
        for(int j=1;j<n;j++)
    {
        int x=v[i][j][0],y=v[i][j][1];
        c[x][y]|=a[i][j];
        if(c[x][y]==3){printf("0\n");return 0;}
    }
    for(int i=0;i<=n;i++)
        for(int j=i+2;j<=n;j+=2)
        if(!c[i][j]) add(i,j),add(j,i),e[i&1]++;
        else st[i]^=c[i][j]-1,st[j]^=c[i][j]-1;
    ll ans=1;
    for(int opt=0;opt<=1;opt++)
    {
        int sum=(n-opt)/2+1;
        if(sum&1)
        {
            cnt=0;
            for(int i=opt;i<=n;i+=2)
                if(!vis[i])
                {
                    cnt--;num=0;
                    dfs(i);
                    if(num&1){printf("0\n");return 0;}
                }
            for(int j=1;j<=e[opt]-cnt;j++)
                ans=(ans<<1)%mod;
        }
        else for(int i=1;i<=e[opt];i++)
            ans=(ans<<1)%mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 155648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int n;
vector<int> a,b;
vector<char> c,d;
int partition(int p,int r)
{
	int sta = a[r];
	int j = p-1;
	for(int i = p;i<r;i++)
	{
		if(sta>=a[i])
		{
			j++;
			swap(a[j],a[i]);
			swap(c[j],c[i]);

		}
		else
		{
			
		}
		
	}
	j++;
	swap(a[r],a[j]);
	swap(c[r],c[j]);
	return j;
}
void quick_sort(int l,int r)
{
	if(l<r)
	{
		int x = partition(l,r);
		quick_sort(l,x-1);
		quick_sort(x+1,r);
	}
}

void marge_sort(int l,int r)
{
	if(r-l==1)return;

	int mid = (l+r)/2;
	//cout<<mid<<endl;
	marge_sort(l,mid);
	marge_sort(mid,r);
	vector<int> v;
	vector<char> v2;
	int i = l,j=mid;
	

	while(i!=mid&&j!=r)
	{
		if(b[i]<=b[j])
		{
			v.push_back(b[i]);
			v2.push_back(d[i]);
			i++;
		}
		else
		{
			v.push_back(b[j]);
			v2.push_back(d[j]);
			j++;
		}
	}
	for(;i<mid;i++){v.push_back(b[i]);v2.push_back(d[i]);}
	for(;j<r;++j){v.push_back(b[j]);v2.push_back(d[j]);}
	for(int k = l;k<r;k++)
	{
		b[k]=v[k-l];
		d[k]=v2[k-l];
	}
}

int main()
{
	cin >> n;
	a = vector<int>(n);
	c = vector<char>(n);
	for(int i =0;i<n;i++)
	{
		cin >>c[i] >> a[i];
	}
	b = a;
	d = c;
	quick_sort(0,n-1);
	marge_sort(0,n);
	bool stable = true;
	for(int i =0;i<n;i++)
	{
		if(c[i]!=d[i])stable = false;
	}
	if(stable)
	{
		cout<<"Stable"<<endl;
	}
	else
	{
		cout<<"Not stable"<<endl;
	}
	

	for(int i = 0;i<n;i++)
	{
		cout<<c[i]<<' '<<a[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 4576
N = int(input())
A = [int(i) for i in input().split()] 


#持ってない ＆次の日上がる→ 買い
#持ってない ＆次の日下がる→ 何もしない
#持っている & 次の日上がる→ 何もしない
#持っている & 次の日下がる→ 売り


hold = False
money = 1000
kabu = 0
lastval = 0
for i in range(1, len(A)):
 #   print(i, A[i-1], A[i], hold)

    if hold == False and A[i-1] < A[i]:
        hold = True
        kabu = money // A[i -1]
        money = money % A[i -1]
        lastval = A[i-1]
#        print("buy")
    if hold == True and A[i-1] > A[i]:
        hold = False
        money = money + kabu * A[i-1]
        kabu = 0
#        print("sell")

if hold == True:
    money = money + kabu * A[-1]

print(money) 




Measured memory_bytes: 62032
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	string s,t;
	 cin>>s;
	 cin>>t;
	 ll ans=0;
	 for(int i=0;i<s.length();i++)
	 {
	 	if(s[i]!=t[i])
	 		ans++;
	 }
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3812
s = input()
stk = []
ret = 0
for i in range(len(s)):
    if len(stk) == 0:
        stk.append(s[i])
    elif stk[-1] == '0':
        if s[i] == '1':
            stk.pop(-1)
            ret += 2
        else:
            stk.append('0')
    else:
        if s[i] == '0':
            stk.pop(-1)
            ret += 2
        else:
            stk.append('1')

print(ret)


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
//#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

ll gcd(ll x, ll y) {
	int r = 0;
	if (x < y) swap(x, y);

	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
	//PAU;
	return 0;
}


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

long long ans = 1;
typedef long long ll;

const int N = 1e6, mod = 998244353LL;

ll cnt[N], d[N];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		cnt[d[i]]++;
	}
	if(d[0]) {
		cout << 0 << "\n";
		return 0;
	}
	sort(d, d + n);
	if(cnt[0] != 1) {
		cout << 0 << "\n";
		return 0;
	}
	ll ans = 1;
	for (int i = 1; i < n; i++) {
		if(!cnt[d[i] - 1])
			return cout << 0 << "\n", 0;
		ans *= cnt[d[i] - 1];
		ans %= mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
using namespace std;
 
int main(){
        int gozen,gogo,people,yen,x,y;
        string c;
        for(int i=0;i<9;i++){
                cin>>c>>gozen>>gogo;
                people=gozen+gogo;
                x=gozen*200;
                y=gogo*300;
                yen=x+y;
                cout<<c<<' '<<people<<' '<<yen<<endl;
        }
        return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int> hist(s.size() + 1, 0);
    for (int i = 1; i <= s.size(); i++)
    {
        hist[i] = hist[i - 1] + (s[i - 1] == 'T' ? 1 : -1);
    }
    const auto max_pos = std::distance(hist.begin(), max_element(hist.begin(), hist.end()));
    cout << (hist[max_pos] + abs(hist[max_pos] - hist[s.size()])) << endl;
}


Measured memory_bytes: 1412
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

int main()
{

    string str;

    cin>>str;

    if(str=="Sunny")cout<<"Cloudy"<<endl;
    else if(str=="Cloudy")cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;



    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1182&lang=jp
using namespace std;
typedef long long ll;
#define INF 1<<25
#define LINF 1LL<<60
#define MAX_D 20010

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n, m, c, s, g;
	while (cin >> n >> m >> c >> s >> g, n | m | c | s | g) {
		/* input */
		vector<vector<vector<int>>> dist(c + 1, vector<vector<int>>(n + 1, vector<int>(n + 1, INF)));
		for (int i = 0;i < m;i++) {
			int x, y, d, c; cin >> x >> y >> d >> c;
			dist[c][x][y] = dist[c][y][x] = min(d,dist[c][x][y]);
		}
		vector<int> p(c + 1);
		for (int i = 1; i <= c;i++) cin >> p[i];
		vector<vector<int>> q(c + 1);
		vector<vector<int>> r(c + 1);
		vector<vector<int>> fare(c + 1, vector<int>(MAX_D, 0));
		for (int i = 1; i <= c;i++) {
			for (int j = 1; j <= p[i] - 1;j++) {
				int a; cin >> a;
				q[i].push_back(a);
			}
			q[i].push_back(INF);
			for (int j = 1; j <= p[i];j++) {
				int a; cin >> a;
				r[i].push_back(a);
			}
			int at = 0;
			for (int j = 1; j < MAX_D;j++) {
				fare[i][j] = fare[i][j - 1] + r[i][at];
				if (j == q[i][at]) at++;
			}
		}

		for (int C = 1; C <= c;C++) {
			for (int i = 1; i <= n;i++) {
				for (int j = 1; j <= n;j++) {
					for (int k = 1; k <= n;k++) {
						dist[C][j][k] = min(dist[C][j][k], dist[C][j][i] + dist[C][i][k]);
					}
				}
			}
		}
		vector<vector<int>> cost(n + 1, vector<int>(n + 1, INF));
		for (int i = 1; i <= n;i++) cost[i][i] = 0;

		for (int C = 1; C <= c;C++) {
			for (int i = 1; i <= n;i++) {
				for (int j = 1; j <= n;j++) {
					if (dist[C][i][j] == INF)continue;
					cost[i][j] = min(cost[i][j], fare[C][dist[C][i][j]]);
				}
			}
		}

		for (int i = 1; i <= n;i++) {
			for (int j = 1; j <= n;j++) {
				for (int k = 1; k <= n;k++) {
					cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
				}
			}
		}
		cout << ((cost[s][g] == INF) ? -1 : cost[s][g]) << endl;
	}
}

Measured memory_bytes: 5532
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
li=[]
for i in range(N):
  li.append(min(A[i],B[i]))
  if B[i]>A[i]:
    if A[i+1]>=B[i]-A[i]:
      A[i+1]-=B[i]-A[i]
      li.append(B[i]-A[i])
    else:
      li.append(A[i+1])
      A[i+1]=0
      li.append(A[i+1])
print(sum(li))

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

int main() {
    int N,T,A; cin >> N >> T >> A;
    int H[N];
    cin >> H[1];
    int min_diff = abs(1000*A-(1000*T-H[1]*6));
    int index=1;
    for (int i=2;i<=N;i++) {
        cin >> H[i];
        int diff = abs(1000*A-(1000*T-H[i]*6));
        if (diff<min_diff) min_diff=diff,index=i;
    }
    cout << index << endl;
}

Measured memory_bytes: 256
//
// Created by Daiki Kuyoshi on 2020/05/02.
//

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll X;
    cin >> X;
    ll sum = 100;
    ll i = 1;
    while(1){
        sum += sum*0.01;
        if(sum >= X){
            break;
        }
        i++;
    }
    cout << i << endl;
}

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

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

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

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

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    bool isvalid = true;
    REP(i, N){
        if (A[i] % 2 == 0){
            if (A[i] % 3 != 0 && A[i] % 5 != 0){
                isvalid = false;
                break;
            }
        }
    }

    if (isvalid){
        print("APPROVED");
    } else {
        print("DENIED");
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    string s;
    cin>>s;
    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi") cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
n, x = list(map(int, input().split()))
li = list(map(int, input().split()))
d = []
d.append(0)
for l in li:
  d.append(d[-1] + l)
cnt = 0
for hoge in d:
  if(hoge <= x):
    cnt = cnt + 1
print(cnt)

Measured memory_bytes: 38384
#include<cstdio>
void swap(int &x,int &y) {int t=x;x=y;y=t;}
int min(int x,int y) {return x<y?x:y;}
int main()
{
	int a,b,c,x,y;scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(x>y) {swap(x,y);swap(a,b);}
	int ans=min(2*c*x,a*x+b*x)+min(2*c*(y-x),b*(y-x));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int n,s[100000],q,t,ans=0,l,m,r;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>s[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>t;
    l=0;r=n;
    while(l<r){
      m=(l+r)/2;
      if(s[m]==t){
	ans++;
	break;
      }
      else if(s[m]<t)
	l=m+1;
      else
	r=m;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

class Main{
    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String line;

	line = br.readLine();
	int n = Integer.parseInt(line.substring(0,line.indexOf(' ')));
	int q = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
	Deque<Process> queue = new ArrayDeque<Process>();
	
	for(int i = 0;i < n;i++){
	    line = br.readLine();
	    String name = line.substring(0,line.indexOf(' '));
	    int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
	    queue.offer(new Process(name,time));
	}
	int elapse = 0;
	StringBuilder sb = new StringBuilder();
	while (!queue.isEmpty()) {
	    Process p = queue.poll();
	    if (p.getTime() <= q) {
		elapse += p.getTime();
		sb.append(p.getName() + " " + elapse + "\n");
	    } else {
		p.setTime(p.getTime() - q);
		elapse += q;
		queue.offer(p);
	    }
	}
	System.out.print(sb);
    }
}
class Process{
    private String name;
    private int time;
    public Process(String name,int time){
	this.name = name;
	this.time = time;
    }
    public void setName(String name){
	this.name = name;
    }
    public String getName(){
	return this.name;
    }
    public void setTime(int time){
	this.time = time;
    }
    public int getTime(){
	return this.time; 
    }
}
      



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

#define ll long long 
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ar array
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x; cin >> x;
	if (x >= 30) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

int main(void){
	int i,j,k,sign=0;
	int n;
	
	scanf("%d",&n);
	
	char s[n+1][11];
	int p[n+1],rank[n+1],min=0;
	
	for(i=0;i<=n;i++){
		for(j=1;j<=10;j++){
			s[i][0]='\n';
		}
	}
	for(i=0;i<=n;i++){
		rank[i]=0;
	}
	for(i=0;i<=9;i++){
		s[0][i]='z';
	}
	p[0]=0;
	
	for(i=1;i<=n;i++){
		scanf(" %s %d",s[i],&p[i]);
	}
	
	for(k=1;k<=n;k++){
			min=0;
		for(i=1;i<=n;i++){
			if(rank[i]!=0){
			}else{
				for(j=1;j<=10;j++){
					if(strcmp(s[i],s[min])==0){
						if(p[i]>p[min]){
							min=i;
						}
						break;
					}else if(strcmp(s[i],s[min])<0){
						min=i;
						break;
					}else if(strcmp(s[i],s[min])>0){
						break;
					}
				}
			}
		}
		rank[min]=1;
		printf("%d",min);
		if(k!=n){
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<ll,int>
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=1e5+3;
int dp[N]= {},n,h[N]={};
int solve(int idx)
{
    if (idx>=n)
        return 0;
    int &ret=dp[idx];
    if (~ret)
        return ret;
    ret=(int)2e9;
    ret=min(ret,solve(idx+1)+abs(h[idx+1]-h[idx]));
    ret=min(ret,solve(idx+2)+abs(h[idx+2]-h[idx]));
    return ret;
}
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    memset(dp,-1,sizeof(dp));
    cin>>n;
    lp(i,0,n-1) cin>>h[i];
    h[n+1]=h[n+2]=h[n]=h[n-1];
    cout<<solve(0)<<"\n";
    return 0;
}

Measured memory_bytes: 4096
#include "stdio.h"
#include "math.h"

#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0228 : Seven Segments **/
int main()
{
	string list[10];
	list[0] = "0111111";
	list[1] = "0000110";
	list[2] = "1011011";
	list[3] = "1001111";
	list[4] = "1100110";
	list[5] = "1101101";
	list[6] = "1111101";
	list[7] = "0100111";
	list[8] = "1111111";
	list[9] = "1101111";
	int n, in;

	while (cin >> n, n>0) {
		string now="0000000";
		rep(k, n) {
			cin >> in;
			string signal;
			rep(i, 7) {
				if (list[in][i] != now[i])
					signal+='1';
				else
					signal+='0';
			}
			now = list[in];
			cout << signal << endl;
		}
	}
	return 0;
}

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

#define f first
#define s second
#define pb push_back

using namespace std;

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

const int maxk = 17 + 1;
const int maxn = 1 * 1e5 + 17;

int N, M, S, T;
ll DPS[maxn], DPT[maxn];

vector<pill> graph[maxn];

void solve(int from, ll *DP)
{
    for (int i = 0; i < maxn; i++) DP[i] = 1LL << 62;
    priority_queue<pll, vector<pll>, greater<pll> > pq;
    DP[from] = 0; pq.push({DP[from], from});

    while (!pq.empty()) {
        int u = pq.top().s;
        pq.pop();

        for (auto e : graph[u]) {
            ll len = e.s.f;
            if (DP == DPT) len = e.s.s;

            if (DP[u] + len < DP[e.f])
                DP[e.f] = DP[u] + len,
                pq.push({DP[e.f], e.f});
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> N >> M >> S >> T;
    for (int i = 1; i <= M; i++) {
        int x, y; ll z, w; cin >> x >> y >> z >> w;
        graph[x].pb({y, {z, w}}); graph[y].pb({x, {z, w}});
    }

    solve(S, DPS); solve(T, DPT);

    priority_queue<pli, vector<pli>, greater<pli> > ans;
    for (int i = 1; i <= N; i++) ans.push({DPS[i] + DPT[i], i});

    for (int i = 0; i <= N - 1; i++) {
        while (ans.top().s <= i) ans.pop();
        cout << 1000000000000000LL - ans.top().f << endl;
    }

    return 0;
}

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

namespace m_solutions2020_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CIn.ReadInt();
            var K = CIn.ReadInt();
            var A = CIn.ReadIntArray(N);
            for(var i = 0; i <= N - K - 1 ; i++)
            {
                if (A[0 + i] < A[K + i])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
           
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


Measured memory_bytes: 49572
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int r=0, b=0;
            foreach (char c in s)
            {
                if (c == 'R') r++;
                else if (c == 'B') b++;
            }

            if (r > b) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13140
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll unsigned long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e18;
int main()
{
IOS
ll n;
cin>>n;
ll p=0;
for(ll i=2;i<=sqrt(n);i++)
{
    ll cnt=0;
    while(n%i==0)
    {
        cnt++;
        n/=i;
    }
    ll c=1+8*cnt;
    c=sqrt(c);
    c-=1;
    c/=2;
    if(c>0)
        p+=c;
}
if(n>1)
    p++;
cout<<p;
return 0;
}


Measured memory_bytes: 3700
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N;
vi A;
int neg;
int sum;
int absmin=INF;

signed main(){

    in(N);
    rep(i,N){
        int a;
        in(a);
        absmin=min(absmin,abs(a));
        if(a<0) neg++;
        A.pb(a);
    }
    for(auto e:A){
        sum+=abs(e);
    }

    out(neg%2==0?sum:sum-absmin*2);

    return 0;
}


Measured memory_bytes: 1528
/// You just can't beat the person who never gives up
/// ICPC next year


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
void offset(vector<int>&a,int x) {
    for(int i = 0; i < sz(a);i++) {
        a[i] = x;
    }
}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};


// auto cmp = [](pair<int,int>a,pair<int,int>b) {if(a.first==b.first)return a.second>b.second;
//      else return a.first > b.first;
//  };
//  multiset<pair<int,int>,decltype(cmp)>fc(cmp);
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash> safe_map;
};

const int MAXN = 5e5+ 10;

#define int long long
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}
int dp[MAXN];
int a[MAXN], b[MAXN];
int32_t main() {
    int n, h;
    cin >> h >> n;
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for(long long & j : dp) {
        j = INT_MAX;
    }
    dp[0] = 0;
    for(ll i = 0; i < n; i++) {
        for(ll j = 0; j <= h; j++) {
            dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
        }
    }
    int mini = INT_MAX;
    for (ll i = h; i < MAXN; i++) mini = min(mini, dp[i]);
    cout << mini;
    return 0;
}

Measured memory_bytes: 7560
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;

void main()
{
  auto s = readln.chomp;
  auto c = new char[](s.length);
  int index;
  foreach (i; 0..s.length) {
    if (s[i] == 'B') {
      if (index != 0) {
        index--;
      }
    } else {
      c[index] = s[i];
      index++;
    }
  }
  foreach (i; 0..index) {
    c[i].write;
  } 
  writeln("");
}


Measured memory_bytes: 256