akhauriyash/Code-Regression huggingface dataset:
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;


int main(){
    int a, b, c, k; cin >> a >> b >> c >> k;
    int cnt = 0;
    while(a >= b){
        if(cnt >= k) break;
        b *= 2;
        cnt++;
    }

    while(b >= c){
        if(cnt >= k) break;
        c *= 2;
        cnt++;
    }

    if(a < b && b < c) cout << "Yes\n";
    else cout << "No\n";
    return 0;
 }


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  998244353
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll GCD(ll a, ll b) {
  if (b == 0) return a;
  else return GCD(b, a%b);
}
//--MAIN-----------------------------------
void Main() {
    ll T; cin>>T;
    rep(rrr,T){
        ll a,b,c,d; cin>>a>>b>>c>>d;

        if(a<b){cout<< "No" <<"\n"; continue;}
        if(b>d){cout<< "No" <<"\n"; continue;}
        if(b<=c){cout<< "Yes"<<"\n"; continue;}

        ll x=GCD(d,b);

        a%=x;
        a=d-a;
        a%=x;

        /*bis*/ ll low= -1 , high= INF2 ; // min-1, max+1
        while( abs(high-low)>1 ){ ll mid=(high+low)/2;
            bool ok=false;
            if(mid!=0){
                if(x>=LLONG_MAX/mid) ok=true;
            }
            if(a+x*mid>d-b) ok=true;
            ( ok ? high : low ) = mid;
        }// if ok, okdir = mid

        if(a+x*high<d-c){ cout<< "No" <<"\n";}
        else{ cout<< "Yes" <<"\n";}
    }
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
from numpy import *;i,p,q=int32,input,searchsorted;p();A,B,c=i(p().split()),i(p().split()),0;
for k in range(1,30):
  a=A%(1<<k);a,b=sort(hstack((a,a-2**k))),B%(1<<k);c+=(sum(q(a,2**k-b)-q(a,2**(k-1)-b)))%2<<k-1
print(c)


Measured memory_bytes: 37024
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

string s;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> s;
    solve();
}

// 1 ≦ |s| ≦ 10 (|s| は s の長さを表す)
// s は文字 0, 1, B のみからなる。
// 正解は空文字列ではない。

// string s
// 最終的にエディタに表示されている文字列を出力せよ。（「制約」セクションで述べたように、この文字列が空になるような入力は与えられない）
void solve(){
    ll n=s.size();
    string ans;
    rep(i,n){
        if(s[i]=='B'){
            if(ans.size()==0)continue;
            ans=ans.substr(0,ans.size()-1);
        }else{
            ans+=s[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int dp[16][64];

int main() {
    dp[0][0] = 1;
    rep (k, 10) {
        for (int i = 10; i >= 0; i--) {
            rep (j, 64) if (dp[i][j]) dp[i+1][j+k] += dp[i][j];
        }
    }
    for (;;) {
        int n, s;
        scanf("%d%d", &n, &s);
        if (n == 0 && s == 0) return 0;
        printf("%d\n", n < 16 && s < 64 ? dp[n][s] : 0);
    }
}

Measured memory_bytes: 0
import sys

N = int(input())
#Bs = list(map(int, input().split()))
Bs = [B - 1 for B in map(int, input().split())]

anss = []
for _ in range(N):
    iNow = -1
    for i in reversed(range(len(Bs))):
        if Bs[i] == i:
            iNow = i
            break
    else:
        print(-1)
        sys.exit()

    anss.append(iNow)

    Bs = Bs[:iNow] + Bs[iNow+1:]

print('\n'.join(map(str, [ans+1 for ans in anss[::-1]])))


Measured memory_bytes: 39024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int H, W, N; cin >> H >> W >> N;
  int a[N]; rep(i,N) cin >> a[i];
  vector<int> b;
  rep(i,N) {
    rep(j,a[i]) b.push_back(i+1);
  } 


  int c[H][W];
  int idx = 0;
  rep(row,H) rep(col,W){
    c[row][col] = b[idx];
    idx++;
  }
  rep(row,H) if (row%2) reverse(c[row],c[row]+W);

  rep(row,H) {
    rep(col,W){
    if (col>0) cout << " ";
    cout << c[row][col];
    }
    cout << endl;
  }






  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
int func(int n){
	int count=0,i;
	for(i=1;i<=n;++i){
		if(n%i==0)count++;
	}
	return count;
}
int main(void){
	int n,i;
	cin>>n;
	for(i=1;i<=n;i+=2){
		if(func(i)==8)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}
var ans = [];

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  solve(a[0],1,n,a);
  solve(a[n-1],0,n-1,a);
  var x = 0;
  for(var i = 0; i < ans.length; i++)x = Math.max(x,ans[i]);
  return x;
}
function solve(xgcd,l,r,a){
  if(r-l <= 1){ans.push(xgcd); return;}
  var m = l+r >> 1;
  var t = xgcd;
  for(var i = l; i < m; i++)t = gcd(t,a[i]);
  solve(t,m,r,a);
  t = xgcd;
  for(var i = m; i < r; i++)t = gcd(t,a[i]);
  solve(t,l,m,a);
}

Measured memory_bytes: 33272
#include<bits/stdc++.h>
using namespace std;
double Sequence(double a,int n)
{
if(n==10)return a*2;
if(n%2==0)return a*2+Sequence(a*2,n+1);

return a/3+Sequence(a/3,n+1);
}
int main()
{
double n=0,a;
while(cin>>a){
n=a+Sequence(a,2);
cout<<setprecision(8)<<n<<endl;
}
}

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

int main(){
	string sa;
	int ca=0;
	while(cin>>sa){
		string sb=sa;
		reverse(sa.begin(),sa.end());
		string sc=sa;
		if(sb==sc){ca+=1;}
		}
		
		cout<<ca<<endl;
		return 0;
	}

Measured memory_bytes: 3148
stdin.ReadLine().Split(' ') 
|> Array.map int
|> Array.groupBy (fun x -> x)
|> Array.where (fun x -> fst(x) = 5 && snd(x).Length = 2 || fst(x) = 7 && snd(x).Length = 1)
|> Array.length
|> fun x -> if x = 2 then "YES" else "NO"
|> printfn "%s"

Measured memory_bytes: 14940
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
using namespace std;
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 200005
int n,a[N],tong[N];ll ans;
void failed(){puts("-1");exit(0);}
int main(){
	n=read();
	rep (i,1,n) a[i]=read();
	if (a[1]!=0) failed();
	rep (i,2,n) if (a[i]-a[i-1]>1) failed();
	for (int i=1;i<=n;){
		int st=i,ed=i;
		while (ed<n&&a[ed+1]>=a[ed]) ed++;
		rep (j,st,ed) tong[a[j]]++;
		rep (j,a[st],a[ed]){
//			cerr<<"j="<<j<<": "<<tong[j]<<'\n';
			ans+=(ll)j*(tong[j]-1);
		}
		ans+=a[ed];
//		if (a[st]>1) ans+=a[st];
		rep (j,st,ed) tong[a[j]]--;
		i=ed+1;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1792
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, Q = MAP()
    S = input() + 'E'
    t = [0] * (N + 1)
    for i in range(N):
        if S[i:i+2] == 'AC':
            t[i + 1] = t[i] + 1
        else:
            t[i + 1] = t[i]
    ans = []
    for i in range(Q):
        l, r = MAP()
        ans.append(t[r - 1] - t[l - 1])
    for i in range(Q):
        print(ans[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 53960
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}



Measured memory_bytes: 5208
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   int N; cin >> N;
   vector<int> cnt(N + 1, 0);
   rep(i, 0, N - 1) {
     int A; cin >> A;
     cnt.at(A)++;
   }

   rep(i, 1, N + 1) cout << cnt.at(i) << endl;
 }


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

int main() {
  int N, K;
  long long min = 1000000000000000000;
  cin >> N >> K;
  vector<int> h(N);
  vector<long long> dp(N);
  for(int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(0) - h.at(1));
  for(int i = 1; i < N-1; i++) {
    if(i >= K-1) {
      for(int j = 0; j < K; j++) {
        if(min > dp.at(i-j) + abs(h.at(i-j) - h.at(i+1)))
          min = dp.at(i-j) + abs(h.at(i-j) - h.at(i+1));     
      }
    }else{
      for(int j = 0; j < i+1; j++) {
        if(min > dp.at(i-j) + abs(h.at(i-j) - h.at(i+1)))
          min = dp.at(i-j) + abs(h.at(i-j) - h.at(i+1));
      }
    }
    dp.at(i+1) = min;
    min = 1000000000000000000;
  }
  cout << dp.at(N-1);
}


Measured memory_bytes: 1408
inp = int(input())

data = input().split(' ')
count = 0
for i in range(0, inp):
  if int(data[i]) % 2 != 0:
    pass
  if int(data[i]) % 2 == 0:
    if int(data[i]) % 3 != 0 and int(data[i]) % 5 != 0:
      count += 1

if count >= 1:
  print("DENIED")
else:
  print("APPROVED")

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

using P = pair<int,int>;

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

int h,w,r,c;
bool horz[510][510],vert[510][510];
bool ok[510][510];

void solve(){
	if(h )
	r--;c--;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) ok[i][j] = false;
	}
	for(int i = 0;i <= h;i++){
		for(int j = 0;j < w;j++) cin >> horz[i][j];
		if(i != h){
			for(int j = 0;j <= w;j++) cin >> vert[i][j];
		}
	}
	queue<P> que;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) que.emplace(i,j);
	}
	while(!que.empty()){
		int x,y;
		tie(x,y) = que.front(); que.pop();
		if(ok[x][y]) continue;
		bool flag[2] = {};
		for(int i = 0;i < 4;i++){
			int nx = x + dx[i],ny = y + dy[i];
			if(nx < 0 || nx >= h || ny < 0 || ny >= w || ok[nx][ny]){
				if(i % 2) flag[vert[x][y + i / 2]] = true;
				else flag[horz[x + i / 2][y]] = true;
			}
		}
		if(flag[0] && flag[1]){
			ok[x][y] = true;
			for(int i = 0;i < 4;i++){
				int nx = x + dx[i],ny = y + dy[i];
				if(nx >= 0 && nx < h && ny >= 0 && ny < w && !ok[nx][ny]) que.emplace(nx,ny);
			}
		}
	}
	bool ans = false;
	for(int i = 0;i < 4;i++){
		int x = r + dx[i],y = c + dy[i];
		if((i % 2 && !vert[r][c + i / 2]) || (i % 2 == 0 && !horz[r + i / 2][c])){
			if(x < 0 || x >= h || y < 0 || y >= w || ok[x][y]) ans = true;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main(){
	while(cin >> h >> w >> r >> c,h) solve();
}


Measured memory_bytes: 7868
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
int main(){
    int N;
    while(cin>>N,N){
        if(N==1){cout<<"deficient number"<<endl;continue;}
        int S=1;
        for(int i=2;i*i<N;i++){
            if(N%i==0){S+=i;S+=N/i;}
        }
        if(N>S)cout<<"deficient number"<<endl;
        else if(N<S)cout<<"abundant number"<<endl;
        else cout<<"perfect number"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  while(1){
    int n,r,a,b,yama[51],tmp[51];
    cin>>n>>r;
    if(n+r==0)break;
    for(int i=0;i<=n;i++)yama[i]=i;
    for(int i=0;i<r;i++){
      cin>>a>>b;
      for(int j=0;j<b;j++)tmp[j]=yama[n-(a+b-2)+j];
      for(int j=0;j<a-1;j++)yama[n-(a+b-2)+j]=yama[n-a+2+j];
      for(int j=0;j<b;j++)yama[n-b+1+j]=tmp[j];
    }
    cout<<yama[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

void print(const vector<string> &page) {
  for(const auto &line : page) {
    cout << line << endl;
  }
  cout << "#" << endl;
}

int main(){
  for(int plen, cnum, width, cspace; cin >> plen && plen;) {
    cin >> cnum >> width >> cspace;
    cin.ignore();

    const int len = cnum * width + cspace * (cnum - 1);
    vector<string> page(plen, string(len, '.'));

    int r = 0, c = 0;
    for(string line; getline(cin, line) && line != "?";) {
      bool first = true;
      while(line.size() || first) {
	string word;
	if(line.size() >= width) {
	  word = line.substr(0, width);
	  line = line.substr(width);
	}
	else {
	  word = line;
	  line = "";
	}

	const int offset = c * (width + cspace);
	for(int i = 0; i < word.size(); ++i) {
	  page[r][i + offset] = word[i];
	}

	if(++r == plen) {
	  r = 0;
	  if(++c == cnum) {
	    c = 0;
	    print(page);
	    page = vector<string>(plen, string(len, '.'));
	  }
	}

	first = false;
      }
    }

    if(any_of(page[0].begin(), page[0].end(), [](char c) { return c != '.';})) {
      print(page);
    }
    cout << "?" << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    string S;
    cin >> S;
    ll Y=stoll(S.substr(0,4));
    ll M=stoll(S.substr(5,2));
    ll D=stoll(S.substr(8,2));
    vector<ll> vec={Y,M,D};
    vector<ll> vec2={2019,4,30};
    if(vec<=vec2)print("Heisei")
    else print("TBD")

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map &:to_i
bs = gets.split.map &:to_i

asum = as.sum
bsum = bs.sum

if asum < bsum
  puts -1
  exit
end

pos = []
neg = 0
cnt = 0
as.zip(bs) do |(a, b)|
  c = a - b
  if c < 0
   	neg += c
    cnt += 1
  elsif c > 0
    pos << c
  end
end

pos = pos.sort.reverse

while neg < 0
  neg += pos.shift
  cnt += 1
end

p cnt

Measured memory_bytes: 24436
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//SOLVE
void solve(void)
{
  int X;cin>>X;
  int ANS = (X/11)*2;
  X %= 11;
  if(X == 0);
  else if(X <= 6)ANS++;
  else ANS += 2;
  cout<<ANS<<endl;

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    vector<ll> a(3 * N);
    for (int i = 0; i < 3 * N; i++) {
      cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    ll res = 0;
    for (int i = 0; i < N; i++) {
      res += a[2 * i + 1];
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2560
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

a,b = inp
p (a-1)*(b-1)


Measured memory_bytes: 1788
/*
 * taete.cpp
 *
 *  Created on: 2018/04/26
 *      Author: J01003
 */
#include<iostream>
using namespace std;

int main(){

	int s,t;
	s=1;
	while(s>0){
		cin>>t;
		if(t==0)break;
		cout<<"Case"<<" "<<s<<": "<<t<<endl;
		s=s+1;
	}

	return 0;
}







Measured memory_bytes: 2984
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;


int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b, a%b);
}

int main()
{
  int A,B;
  cin >> A >> B;
  if(A >= 13) cout << B;
  else if(A >= 6) cout << B/2;
  else cout << "0";
}


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

int main () {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b\n";
	} else if (a > b) {
		cout << "a > b\n";
	} else {
		cout << "a == b\n";
	}
	return 0;
}

Measured memory_bytes: 1124
N,K = map(int,input().split())
A = list(map(int, input().split()))
temp_1 = 1 #今
temp_2 = 1 #昔

for i in range(N):
    if i>(K-1):
        if A[i-K]<A[i]:
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 94232
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  constexpr int d[] = {2, 3, 5};
  constexpr int64_t INF = numeric_limits<int64_t>::max();

  rep(i, T) {
    vector<int> cost(3);
    int64_t N, D;
    cin >> N >> cost[0] >> cost[1] >> cost[2] >> D;

    map<int64_t, int64_t> dp;
    priority_queue<int64_t> q;

    dp[N] = 0;
    q.push(N);
    while (!q.empty()) {
      int64_t v;
      v = q.top();
      q.pop();

      rep(i, 3) {
        if (v / d[i] > 0) {
          int64_t L = v / d[i];
          int64_t R = (v + d[i] - 1) / d[i];

          if (dp.find(L) == dp.end()) {
            dp[L] = INF;
            q.push(L);
          }
          chmin(dp[L], dp[v] + v % d[i] * D + cost[i]);

          if (dp.find(R) == dp.end()) {
            dp[R] = INF;
            q.push(R);
          }
          chmin(dp[R], dp[v] + (d[i] - v % d[i]) % d[i] * D + cost[i]);
        }
      }
    }
    int64_t result = INF;
    for (auto p : dp) {
      int64_t a, b;
      tie(a, b) = p;
      int64_t w = 1e18;
      if (a < w / D) {
        w = a * D;
      }
      chmin(result, w + b);
    }
    cout << result << endl;
  }
  return 0;
}

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

int main(void){
  int n; cin >> n;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i*j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

ans=1001001001001
cost_sum=0

for i in range(min(a),max(a)+1):
    for j in range(n):
        cost=(a[j]-i)**2
        cost_sum+=cost
        if ans < cost_sum:
            continue
    if ans > cost_sum:
        ans = cost_sum
    cost_sum=0
print(ans)

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

int main() {
    int N, M;
    std::cin >> N >> M;

    int s[M];
    int c[M];
    for (int i = 0; i < M; ++i) {
        std::cin >> s[i] >> c[i];
    }

    int max, min;
    if (N == 1) {
        min = 0;
        max = 9;
    } else if (N == 2) {
        min = 10;
        max = 99;
    } else {
        min = 100;
        max = 999;
    }

    for (int i = min; i <= max; ++i) {
        const std::string str = std::to_string(i);
        bool ok = true;
        for (int j = 0; j < M; ++j) {
            if (str[s[j] - 1] != ('0' + c[j])) {
                ok = false;
                break;
            }
        }  

        if (ok) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var x = int.Parse(spl[1])-1;
        var y = int.Parse(spl[2])-1;
        
        var counts = new int[n];

        var tbl = new int[n][];
        for (int i = 0; i < n; i++) {
            tbl[i] = new int[n];
        }
        
        for(int i=0; i<n; i++) {
            for(int j=i+1; j<n; j++) {
                int ix = Math.Abs(i - x);
                int yj = Math.Abs(j - y);

                int v1 = j - i;
                int v2 = ix + 1 + yj;
                tbl[i][j] = Math.Min(v1, v2);
                counts[tbl[i][j]]++;
            }
        }
        
        var bu = new StringBuilder();
        for(int i=1; i<=n-1; i++) {
            bu.AppendLine(counts[i].ToString());
        }

        return bu;
    }

    static int min(int x, int y) {
        if (x == 0) return y;
        if (y == 0) return x;
        return Math.Min(x, y);
    }
}

Measured memory_bytes: 27908
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using Flow = int;
struct FlowEdge {
  int src, dst;
  Flow cap;
  int rev;
  FlowEdge(const int s = 0, const int d = 0, const Flow c = 0, const int r = 0) : src(s), dst(d), cap(c), rev(r) {}
};

using FlowEdges = std::vector<FlowEdge>;

class FlowGraph {
  std::vector<FlowEdges> g;

public:
  FlowGraph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  FlowEdges &operator[](const int i) & { return g[i]; }

  void addEdge(const int src, const int dst, const Flow c = 1) {
    g[src].emplace_back(src, dst, c, g[dst].size());
    g[dst].emplace_back(dst, src, 0, g[src].size() - 1);
  }
};

// Change it to 'FlowGraph &g' when you need a residual network
template<Flow inf = std::numeric_limits<Flow>::max() / 8> Flow fordFulkerson(FlowGraph g, const int source, const int sink) {
  std::vector<int> used(g.size());
  std::function<Flow(int, Flow)> dfs = [&](int v, Flow f) -> Flow {
    if (v == sink) return f;
    used[v] = true;
    for (auto &e : g[v]) {
      if (used[e.dst] || e.cap <= 0) continue;
      Flow d = dfs(e.dst, min(f, e.cap));
      if (d <= 0) continue;
      e.cap -= d;
      g[e.dst][e.rev].cap += d;
      return d;
    }
    return 0;
  };
  Flow s = 0;
  for (;;) {
    std::fill(used.begin(), used.end(), false);
    Flow f = dfs(source, inf);
    if (f == 0) return s;
    s += f;
  }
}

main {
  int X, Y, E;
  cin >> X >> Y >> E;
  FlowGraph g(X + Y + 2);
  rep(i, X) g.addEdge(X + Y, i, 1);
  rep(i, Y) g.addEdge(X + i, X + Y + 1, 1);
  while (E--) {
    int x, y;
    cin >> x >> y;
    g.addEdge(x, X + y);
  }
  cout << fordFulkerson(g, X + Y, X + Y + 1) << endl;
}

Measured memory_bytes: 4392
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();

		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			X += (D-1)/A +1;
		}

		System.out.println(X);
	}

}


Measured memory_bytes: 25300
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

ll N;
const int MOD = 1000000007;
string acgt = "ACGT";
map<pair<ll, string>, ll> memo;
ll dfs(ll n, string s) {
    if (memo[make_pair(n, s)] != -1) {
        return memo[make_pair(n, s)];
    }

    ll res = 0;
    if (s == "AGC" || s == "GAC" || s == "ACG") {
        res = 0;
    } else if (n == N) {
        res = 1;
    } else {
        for (char c : acgt) {
            if (c == 'C' && s[0] == 'A' && (s[1] == 'G' || s[2] == 'G')) continue;
            res += dfs(n+1, s.substr(1, 2) + c);
            res %= MOD;
        }
    }

    return memo[make_pair(n, s)] = res;
}

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

    cin >> N;
    for (char a : acgt) {
        for (char b : acgt) {
            for (char c : acgt) {
                string seq({a, b, c});
                Rep (i, N+1) {
                    memo[make_pair(i, seq)] = -1;
                }
            }
        }
    }


    // for (auto e : memo) {
    //     cout << e.first.first << " " << e.first.second << " " << e.second << "\n";
    // }
    cout << dfs(0, "TTT") << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  int x;
  int n;
  int counter;
  cin >> a >> b >> c;
  cin >> x;
  counter = 0;

  n = x / 500;
  if(a < n){
    n = a;
  }
 for(int i = 0; i < n + 1; i++){
     int m;
     m = x - 500 * i;
   if(m == 0){
     counter += 1;
     continue;
   }
   if(m < 0){
     continue;
   }
     for(int j = 0; j < m / 100 + 1; j++){
       if(j > b){
         continue;
       }else{
         int l;
         l = m - 100 * j;
         if(l == 0){
       counter += 1;
       continue;
     }
     if(l < 0){
       continue;
     }
             if( l % 50 == 0){
               if(l / 50 > c){
                 continue;
                 }else{
                 counter += 1;
                 }
     }
         }
     }
 }

    cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n; 
    string s = to_string(n);
    int digit = 0;
    for (auto ss : s) {
        digit += ss - '0';
    }
    if (n % digit == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define long long long

using namespace std;

#define MAX_N 600

int a[MAX_N][MAX_N];

void set_levels(int s, int e) {
    if (e - s < 3) return;
    int now = a[s][s],
        m = (s + e) / 2;
    for (int i=s; i<m; i++)
        for (int j=s; j<m; j++)
            a[i][j] = now+1;
    for (int i=m; i<e; i++)
        for (int j=m; j<e; j++)
            a[i][j] = now+1;
    set_levels(s, m);
    set_levels(m, e);
}


int main() {
    int n;
    cin >> n;
    fill(a[0], a[n], 1);
    set_levels(0, n);
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            cout << a[i][j] << (j == n-1 ? '\n' : ' ');
        }
    }
    return 0;
}

Measured memory_bytes: 1664
import java.io.InputStreamReader
import java.io.BufferedReader
import java.util.HashMap

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  br.readLine()

  fun HashMap<Int, Int>.putOrUpdate(key: Int) {
    if(this.containsKey(key)) this.put(key, this.get(key)!!.plus(1))
    else this.put(key, 1)
  }

  val map = hashMapOf<Int, Int>()
  br.readLine().split(" ").map { it.toInt() }
    .forEach { map.putOrUpdate(it) }

  val ans = map.keys.fold(0L) { acc, k ->
    val v: Int = map.get(k)!!
    if(k > v) acc + v else acc + (v - k)
  }

  println(ans)
}

Measured memory_bytes: 61856
///a = 97  z = 122
///A = 65  Z = 90

#include <bits/stdtr1c++.h>
#include <boost/algorithm/string.hpp>

using namespace std;

#define endl                "\n"
#define pb                  push_back
#define pii                 pair<int, int>
#define mp                  make_pair
#define x                   first
#define y                   second
#define all(v)			    ((v).begin()), ((v).end())
#define sz(v)			    ((int)((v).size()))
#define ll                  long long
#define rep(i,n)            for(int i=0 ; i<sz(n) ; i++)
#define lp(i, n)            for(int i = 0 ; (int)i<n ; i++)
#define loop(i, x, n)       for(int i=x ; (int)i<=n ; i++)
#define ms(arr, v)      memset(arr, v, sizeof arr)
typedef vector<vector<char>> vcc;
typedef vector<int> vi;
typedef deque<int> de;

int n, res, temp, mn;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#endif*/
    cin >> n;
    mn = INT_MAX;
    res = 0;
    lp(i, n)
    {
        cin >> temp;
        if(temp <= mn)
        {
            res++;
            mn = temp;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>){
    val s = readLine()!!
    println(when(s){
            "SUN" -> 7
            "MON" -> 6
            "TUE" -> 5
            "WED" -> 4
            "THU" -> 3
            "FRI" -> 2
            "SAT" -> 1
            else -> 0
        })
}

Measured memory_bytes: 31736
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C));

        sc.close();
    }

    static int solve(int A, int B, int C) {
        return Math.max(Math.max(A, B), C) * 9 + A + B + C;
    }
}

Measured memory_bytes: 35800
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
  	int c[3][3];
	int a[3];
	int b[3];
	rep(i, 0, 3) {
        rep(j, 0, 3)  {
            cin >> c[i][j];
        }
    }
	a[0] = 0;
	b[0] = c[0][0] - a[0];
	b[1] = c[0][1] - a[0];
	b[2] = c[0][2] - a[0];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];
	rep(i, 0,3) {
        rep(j, 0, 3) {
		    if (c[i][j] == a[i]+b[j]) {
                continue;
            } else {
			    cout << "No" << endl;
			    return 0;
		    }
        }
	}
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
program main
      implicit none
      integer(4) :: n, k, i
      integer(8), allocatable :: h(:)
      integer(16) :: cnt

      read *, n, k
      allocate( h(n) )
      read *, h

      call quicksort1(h,1,n)

      n=n-k
      cnt = 0
      do i = 1, n
        cnt = cnt+h(i)
      end do
      print *, cnt

end program main
recursive subroutine quicksort1(a, first, last)
  implicit none
  integer(8),intent(inout)::a(*)
  integer,intent(in)::first,last
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  integer(8)::x,t
  integer::i,j

  x = a((first+last)/2)
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i)
     a(i) = a(j)
     a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort1(a, first, i-1)
  if (j+1 < last)  call quicksort1(a, j+1, last)

  return
end subroutine quicksort1


Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n;
        cin >> n;
        if(n == 0) return;

        vector<string> vs(n);
        rep(i, 0, n) cin >> vs[i];

        int l = 0, r = 0;
        int state = 0;
        int ans = 0;

        for (int i = 0; i < n; ++i) {
            int nl = l, nr = r, nstate = state;
            if (vs[i] == "lu") {
                nl = 1;
            }
            if (vs[i] == "ld") {
                nl = 0;
            }
            if (vs[i] == "ru") {
                nr = 1;
            }
            if (vs[i] == "rd") {
                nr = 0;
            }
            if(nr == nl){
                nstate = nr;
            }
            if(nstate != state){
                ans++;
            }
            l = nl;
            r = nr;
            state = nstate;
        }
        cout << ans << endl;

        if (n != 0) solve();
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3800
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

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

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 210000;
int N;
int a[Max], ball[Max];

void list_divisors(int n, vector<int>& result) {
    int a = 2;
    for (int a = 1; a * a <= n; a++) {
        if (n % a == 0) {
            result.push_back(a);
            if (a != n / a) {
                result.push_back(n / a);
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    cin >> N;

    vector<int> divs;
    divs.reserve(1000);

    // rep(i, N) {
    //     list_divisors(i, divs);
    //     sort(divs.begin(), divs.end());
    //     const auto& uend = unique(divs.begin(), divs.end());
    //     divs.erase(uend, divs.end());
    //     for (int div : divs) {
    //         printf("%d ", div);
    //     }
    //     printf("\n");
    //     divs.clear();
    // }
    // return 1;
    inputArray(a+1, N);
    vector<int> ones(Max, 0);

    for (int i = N; i >= 1; i--) {
        if (a[i] == 0) {
            ball[i] = ones[i] % 2;
        } else {
            ball[i] = (ones[i] + 1) % 2;
        }
        if (ball[i] == 1) {
            list_divisors(i, divs);
            sort(divs.begin(), divs.end());
            const auto& uend = unique(divs.begin(), divs.end());
            divs.erase(uend, divs.end());
            for (auto fac: divs) {
                ones[fac]++;
            }
            divs.clear();
        }
        // rep(i, N+1) {
        //     printf("%d", ones[i]);
        // }
        // printf("\n");
    }

    int M = 0;
    string ans = "";
    repd(i, 1, N+1) {
        if (ball[i] > 0) {
            M++;
            ans += to_string(i) + " ";
        }
    }

    output(M);
    output(ans);

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

#ifndef sarthak
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fort(i,v) for(auto i:v)
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) rep(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) rep(i,sizeof(ar)/sizeof(ar[0])) rep(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%d %d",&x,&y)
#define slld2(x,y) scanf("%lld %lld",&x,&y)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pd2(x,y) printf("%d %d\n",x,y)
#define plld2(x,y) printf("%lld %lld\n",x,y)
#define all(ar) ar.begin(), ar.end()
#define endl '\n'
#define sz(x) (int)x.size()
#define len(x) (int)x.length()

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

void solve()
{
    ll n,a,b;
    cin >> n >> a >> b;

    ll xx = n*a;
    cout << min(xx,b) << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout << setprecision(10);
    #ifdef sarthak
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }

    #ifdef sarthak
    cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    #endif
}


Measured memory_bytes: 256