akhauriyash/Code-Regression huggingface dataset:
const main = (input) => {
  var inputs = input.trim().split("\n");
  var N = inputs[0].split(" ")[0]-0;
  var M = inputs[0].split(" ")[1]-0;
  var dlist = [];
  for(var i=0;i<M;i++){
    dlist.push(inputs[i+1].split(" ").filter((v,i)=>i>0).map(v=>v-0));
  }
  var slist = inputs[inputs.length-1].split(" ").map(v=>v-0);

  var ans = 0;
  start:for(var i=0;i<Math.pow(2,N);i++){
    var sw = ("0000000000" + i.toString(2)).slice(-N);
    for(var j=0;j<dlist.length;j++){
      var sum = 0;
      for(var k=0;k<dlist[j].length;k++){
        if(sw[dlist[j][k]-1]=="1") sum+=1;
      }
      if(slist[j] != sum%2) continue start;
    }
    ans++;
  }

  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 21284
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k,q; cin>>n>>k>>q;
  vector<int> a(q); for(int i=0;i<q;i++) cin>>a[i],a[i]--;
  vector<int> b(n,0);
  for(int i=0;i<q;i++) b[a[i]]++;
  for(int i=0;i<n;i++) cout<<(k-q+b[i]>0?"Yes":"No")<<endl;
}

Measured memory_bytes: 4028
N, M = map(int, input().split())
A = []
B = []
AB = []

for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

money = 0
drink = 0
for ab in sorted(AB):
    for _ in range(ab[1]):
        money += ab[0]
        drink += 1
        if drink == M:
            print(money)
            quit()

Measured memory_bytes: 17788
#include<bits/stdc++.h>
using namespace std;
char s[155];
int n,vis[2][144],ans;
int main(){
    scanf("%d%s",&n,s);
    for(int i=0;i<n-1;i++){
    	int cnt=0;
    	memset(vis,0,sizeof(vis));
    	for(int j=0;j<=i;j++) 
    	  if(!vis[0][s[j]]) vis[0][s[j]]=1;
    	for(int j=i+1;j<n;j++)
    	  if(!vis[1][s[j]]) vis[1][s[j]]=1;
    	for(int j='a';j<='z';j++)
    	  if(vis[0][j]&&vis[1][j]) cnt++;
    	ans=max(ans,cnt);
	} 
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int N , A , B , T ;
  cin >> N >> A >> B ;
  T = N * A ;
  if ( T > B ) {
    cout << B << endl;
   }
  else if ( T < B ) {
     cout << T << endl;
   }
  else if ( T = B ) {
     cout << T << endl;
   } 
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int a[100];
    int i;
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for(i = n-1; i > 0; i--) {
        printf("%d ", a[i]);
    }
    printf("%d\n", a[0]);

    return 0;
}


Measured memory_bytes: 2112
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int m, node[500010], lazy[500010];
void init(int n_) {
	m = 1;
	while (m < n_)m *= 2;
}
void eval(int k, int l, int r) {
	if (lazy[k] != 0) {
		node[k] += lazy[k];
		if (r - l > 1) {
			lazy[2 * k + 1] += lazy[k] / 2;
			lazy[2 * k + 2] += lazy[k] / 2;
		}
		lazy[k] = 0;
	}
}

void add(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = m;
	eval(k, l, r);
	if (b <= l || r <= a)return;
	if (a <= l && r <= b) {
		lazy[k] += (r - l) * x;
		eval(k, l, r);
	}
	else {
		add(a, b, x, 2 * k + 1, l, (l + r) / 2);
		add(a, b, x, 2 * k + 2, (l + r) / 2, r);
		node[k] = node[2 * k + 1] + node[2 * k + 2];
	}
}

int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = m;
	eval(k, l, r);
	if (b <= l || r <= a)return 0;
	if (a <= l && r <= b)return node[k];
	int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
	return vl + vr;
}
int n, a;
P b[200010];
signed main() {
	cin >> n;
	init(n);
	int ans = 0;
	rep(i, n) {
		cin >> b[i].first;
		b[i].second = i;
	}
	sort(b, b + n);
	rep(i, n) {
		ans += getsum(b[i].second + 1, n);
		add(b[i].second, b[i].second + 1, 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 10920
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  int v[n];
  for(int i = 0; i < n; i++) cin >> v[i];

  int countEven[100005],countOdd[100005];

  for(int i = 0; i < 100005; i++){
      countEven[i] = 0;
      countOdd[i] = 0;
  }
  for(int i = 0; i < n; i++){
    if(i%2 == 0)  countEven[v[i]]++;
    else  countOdd[v[i]]++;
  }

  int mostFrequentEven = 0, mostFrequentOdd = 0, secondFrequentEven = 0, secondFrequentOdd = 0;
  int valueEven = 0, valueOdd = 0;

  for(int i = 0; i < 100005; i++){
    if(mostFrequentEven <= countEven[i]){
      secondFrequentEven = mostFrequentEven;
      mostFrequentEven = countEven[i];
      valueEven = i;
    }else if(secondFrequentEven < countEven[i]) secondFrequentEven = countEven[i];
    if(mostFrequentOdd <= countOdd[i]){
      secondFrequentOdd = mostFrequentOdd;
      mostFrequentOdd = countOdd[i];
      valueOdd = i;
    }else if(secondFrequentOdd < countOdd[i]) secondFrequentOdd = countOdd[i];
  }

  int ans;
  if(valueOdd != valueEven)
    ans = (n - (mostFrequentOdd + mostFrequentEven));
  else
    ans = min((n - (mostFrequentOdd + secondFrequentEven)), (n - (secondFrequentOdd + mostFrequentEven)));
  cout << ans << "\n";
  return 0;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

int main() { FAST
    string s; cin >> s;
    int mx = 0;
    int cur = 0;
    M00(i, sz(s)) {
        if(s[i] == 'R') {
            cur++;
        } else {
            cur = 0;
        }
        ckmax(mx, cur);
    }
    cout << mx << "\n";
}



Measured memory_bytes: 3668
# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

import collections

S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U == S:
  print(A-1, B)
else:
  print(A, B-1)


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

int main() {
  std::string S;
  std::cin >> S;
  int cnt = 0;
  for(auto &s:S){
    if(s=='o')
      cnt++;
  }
  cnt += 15 - S.size();
  std::string ans = cnt>=8?"YES":"NO";
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int mod = 1e9+7;

int fac[1000007];

int mul(int a,int b) {
	return a*(ll)b % mod;
}

int pow(int a, int b) {
	int rs=1;
	while(b) {
		if(b%2) 
			rs = mul(rs, a);
		a = mul(a,a);
		b/=2;
	}
	return rs;
}

int dv(int a ,int b) {
	return mul(a, pow(b,mod-2));
}

int comb(int a,int b) {
	return dv(fac[a], mul(fac[a-b],fac[b]));
}

int add(int a,int b) {
	a+=b;
	if(a>=mod)
		a-=mod;
	if(a<0)
		a+=mod;
	return a;
}

void pre() {
	fac[0]=1;
	for(ll i=1;i<1e6+5;i++) {
		fac[i] = mul(fac[i-1],i);
	}
}

int32_t main() {
	ll n,m;
	cin>>n>>m;
	ll ans=0,cur=1;
	pre();
	for(ll i=0;i<=n;i++) {
		ll temp = cur * mul(comb(n,i), comb(m-i,n-i));
		temp = mul(temp, fac[n-i]);
		ans = add(ans,temp);
		cur *=-1;
	}
	ll temp = mul(comb(m,n), fac[n]);
	ans = mul(ans, temp);
	cout<<ans<<"\n";
}

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

using namespace std;

#define ar array
#define ll long long

const ll INF=1e18;

int main (){
	int n;
	cin >> n;
	ar<ll,3> a={0,0,0};
	ar<ll,3> buffer;
	ar<ll,3> buffer1;
	for(int i=0; i<n; ++i){
		cin >> buffer[0] >> buffer[1] >> buffer[2];
		buffer1=a;
		a[0]=max(buffer1[1]+buffer[0], buffer1[2]+buffer[0]);
		a[1]=max(buffer1[0]+buffer[1], buffer1[2]+buffer[1]);
		a[2]=max(buffer1[0]+buffer[2], buffer1[1]+buffer[2]);
	}
	cout << max({a[0],a[1],a[2]});
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pow2(x) (ll(1)<<x)
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
#define scan(n) int n;scanf("%d", &n);
using namespace std;
const int sz = 1e5 + 5;
int n,m;
vector<int> adj[sz];
vector<bool> vis(sz,0);
int ans[sz];
int dfs(int node)
{
    For(i,adj[node].size())
    {
        if(!vis[adj[node][i]])
        {
            vis[adj[node][i]]= 1;
            ans[node] = max(ans[node],dfs(adj[node][i]) + 1);
        }
        else
            ans[node] = max(ans[node],ans[adj[node][i]] + 1);
    }
    return ans[node];
}
int main()
{
    memset(ans,0,sizeof ans);
    int n,m;scanf("%d%d", &n, &m);
    For(i,m)
    {
        int a,b;scanf("%d%d",&a, &b);
        adj[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i);
    }
    cout<<*max_element(ans,ans + sz);
}


Measured memory_bytes: 12212
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll h,w,n;
  cin>>h>>w>>n;
  ll lx=h,rx=0,ly=w,ry=0;
  rep(i,n){
    ll x,y,a;
    cin>>x>>y>>a;
    if(a==1) rx=max(rx,x);
    if(a==2) lx=min(lx,x);
    if(a==3) ry=max(ry,y);
    if(a==4) ly=min(ly,y);
  }
  if(ly<=ry||lx<=rx) COUT(0);
  else {
    ll ans=(lx-rx)*(ly-ry);
    COUT(ans);
  }
}

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

int main(){
    int a_ini,b_ini,c_ini;      //A,B,Cの初期値
    cin>>a_ini>>b_ini>>c_ini;

    int a=a_ini;
    int b=b_ini;
    int c=c_ini;

    int count=0;

    int a_temp,b_temp,c_temp;

    while(a%2==0 && b%2==0 && c%2==0){
        a_temp=a;
        b_temp=b;
        c_temp=c;
        a=b_temp/2+c_temp/2;
        b=c_temp/2+a_temp/2;
        c=a_temp/2+b_temp/2;
        count++;
        if(a==a_ini && b==b_ini && c==c_ini){
            count=-1;
            break;
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n,k;
cin >> n >> k;
int high [n];
for(int i=0;i<n;i++){
  cin >> high[i];
}
ll dp [n];
dp [0]=0;
for(int i=1;i<n;i++){
  dp[i]=10e17;
}
for(int i=1;i<n;i++){
  for(int j=1;j<=k;j++){
    if(j>i)break;
    dp[i]=min(abs(high[i]-high[i-j])+dp[i-j],dp[i]);
  }
}
cout << dp[n-1]<<endl;
}
 


Measured memory_bytes: 1408
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int num=sc.nextInt();
    HashSet<String> dic=new HashSet<String>();
    for(int i=0;i<num;i++){
      String order=sc.next();
      String word=sc.next();
      switch(order){
        case ("insert"):
          dic.add(word);
          break;
        case ("find"):
          if(dic.contains(word)) System.out.println("yes");
          else System.out.println("no");
          break;
      }
    }
  }
}



Measured memory_bytes: 253204
#include<iostream>
using namespace std;
int main(){
  string s;
  int n,i,ans=0;
  cin >> n >> s;
  for(i=0;i<n-2;i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>

#define N_MAX 500

int lines[N_MAX][N_MAX] = {0};
int dp[N_MAX][N_MAX];
int dp_sub[N_MAX][N_MAX];

using namespace std;
int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    for(int i = 0;i < M; i++){
        int L, R;
        cin >> L >> R;
        lines[L-1][R-1]++;
        //cout << L << R << "\n";
    }
    
    for(int i = 0; i < N; i++){
        dp_sub[i][i] = lines[i][i];
        dp[i][i] = lines[i][i];
    }
    for(int i = 0; i < N; i++){
        for(int j = i - 1; j >= 0; j--){
            dp_sub[j][i] = dp_sub[j+1][i] + lines[j][i];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            dp[i][j] = dp[i][j-1] + dp_sub[i][j];
        }
    }

    for(int i = 0;i < Q; i++){
        int p, q;
        cin >> p >> q;
        cout << dp[p-1][q-1] << '\n';
        //cout << p << q << "\n";
    }
    
    return 0;
}

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

using namespace std;

string s;
int n;

int main(){
//	freopen("input.inp", "r", stdin);
	getline(cin, s);
	n = s.length();
	int i = 0;
	while (1){
		if (i == n){
			printf("YES");
			return 0;			
		}
		if (i + 5 > n){
			printf("NO");
			return 0;
		}
		if (i + 6 <= n && s.substr(i, 6) == "eraser"){
			i += 6;
		}
		else if (s.substr(i, 5) == "erase"){
			i += 5;
		}
		else if (s.substr(i, 7) == "dreamer" && !(i + 8 <= n && s[i + 7] == 'a')){
			i += 7;
		}
		else if (s.substr(i, 5) == "dream"){
			i += 5;
		}
		else{
			printf("NO");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<int> R(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> R[i];
	}
	int ans = 0;
	int minv = R[0];
	int maxv = -2e9;
	for (int i = 1; i < n; ++i)
	{
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
}

int main()
{
	solve();
	return(0);
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int x,a;
  cin>>x>>a;
  if(x<a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
import sys
import itertools

def construct(nums,ops,expr,i,depth):
    if i==3:
        expr += str(nums[3])+')'*depth
        if expr.count('(')>3: return []
        return [expr]
    else:
        retval = construct(nums,ops,expr+str(nums[i])+ops[i],i+1,depth) 
        for j in range(1,3-depth+1): 
            retval += construct(nums,ops,expr+('('*j)+str(nums[i])+ops[i],i+1,depth+j) 
        for j in range(1,depth+1): 
            retval += construct(nums,ops,expr+str(nums[i])+(')'*j)+ops[i],i+1,depth-j)
        return retval

def solve(indat):
    if indat==[0,0,0,0]: return
    for nums in itertools.permutations(indat, 4):
        for ops in itertools.product(['+','-','*'],repeat=3):
            exprlst = construct(nums,ops,'',0,0)
            for expr in exprlst:
                if eval(expr)==10:
                    print expr
                    return
    print('0')

if __name__=='__main__':
    indat = [[int(x) for x in l.split()] for l in sys.stdin]
    for i in indat: solve(i)

Measured memory_bytes: 6264
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,h,q;
    h=q=0;
    while(~scanf("%d,%d,%d",&a,&b,&c))
    {
        if(a*a+b*b==c*c)
            h++;
        if(a*a-(c/2)*(c/2)==b*b-(c/2)*(c/2))
            q++;
    }
    printf("%d\n%d\n",h,q);

    return 0;
}



Measured memory_bytes: 2036
#include<stdio.h>
int main()
{
	int a[20][20]={0},num,n;
	char card;
	scanf("%d",&n);
	for(int x=0;x<n;x++)
	{
		scanf(" %c %d",&card,&num);
		if(card=='S') a[0][num]=1;
		if(card=='H') a[1][num]=1;
		if(card=='C') a[2][num]=1;
		if(card=='D') a[3][num]=1;
	}
	for(int i=0;i<=3;i++)
	{
		for(int j=1;j<=13;j++)
		{
			if(a[i][j]==1) continue;
			if(a[i][j]==0&&i==0) printf("S %d\n",j);
			if(a[i][j]==0&&i==1) printf("H %d\n",j);
			if(a[i][j]==0&&i==2) printf("C %d\n",j);
			if(a[i][j]==0&&i==3) printf("D %d\n",j);
			
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using std::vector;

void fail() {
    std::cout << -1 << std::endl;
    std::exit(0);
}

int main() {
    int n;
    std::cin >> n;
    vector<int> pos(n, -1);
    for (int i = 0; i < n; ++i) {
        int x, y;
        std::cin >> x >> y;
        --x, --y;
        if (pos[x] >= 0) fail();
        pos[x] = y;
    }

    vector<bool> visited(n, false);
    int cnt = 0;
    for (int x = 0; x < n; ++x) {
        if (visited[x]) continue;
        ++cnt;
        int y = pos[x];
        while (y != x) {
            visited[y] = true;
            y = pos[y];
        }
    }

    std::cout << n - cnt << std::endl;
    return 0;
}



Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  ll r, d,x;
  cin >> r >> d >> x;
  ll res = x;
  REP(i,10){
    res = r*res-d;
    cout << res  << endl;
  }
  return 0;
}


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

using namespace std;

int calc_area(int map[],int start_point, int end_point){
  int base = 0;
  double sum = 0;
  for(int i=start_point+1;i<=end_point;i++){
    sum += base;
    if(map[i] < map[i-1]){
      sum += 0.5;
      base++;
    }else if(map[i] == map[i-1]){
      ;
    }else if(map[i] > map[i-1]){
      sum -= 0.5;
      base--;
    }
  }
  return (int)sum;
}

int main(){
  string input;
  cin>>input;
  int map_size = input.length() + 1;
  int map[map_size];
  vector<int> area;
  int total_area = 0;
  
  map[0] = 0;
  for(int i=0;i<input.length();i++){
    switch(input[i]){
      case '\\':
        map[i+1] = map[i] - 1;
        break;
      case '_':
        map[i+1] = map[i];
        break;
      case '/':
        map[i+1] = map[i] + 1;
        break;
    }
  }
  int start_level = 0;
  bool down;
  for(int i=0;i<map_size-1;i++){
    start_level = map[i];
    down = false;
    for(int j=i+1;j<map_size;j++){
      if(start_level > map[j]){
        down = true;
        continue;
      }
      if(start_level <= map[j]){
        if(down){
          int a = calc_area(map,i,j);
          total_area += a;
          area.push_back(a);
          i = j-1;
          break;
        }else{
          break;
        }       
      }
    }
  }
  cout<<total_area<<endl;

  cout<<area.size();
  for(auto itr = area.begin(); itr != area.end(); ++itr) {
    cout<<" "<<*itr;
  }
  cout<<endl;
}

Measured memory_bytes: 3320
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<string>
#include<set>
using namespace std;

int main(){
	int m,n,count,flg,hannin;
	int member[100][101], info[101];
	//Input
	while(1){
		scanf(" %d",&n);
		if(n==0) break;
		for(int i=0; i < 100; i++){
			for(int j=0; j < 100; j++){
				member[i][j] = 0;
			}
		}
		for(int i=0; i < n; i++){
			scanf(" %d",&member[i][0]);
			for(int j=1; j < member[i][0]+1; j++){
				scanf(" %d",&member[i][j]);
			}
		}
		scanf(" %d",&info[0]);
		for(int i=1; i<info[0]+1; i++){
			scanf(" %d",&info[i]);
		}

		flg = 0;
		hannin = -1;
		for(int i=0; i < n; i++){
			count = 0;
			for(int j=1; j < member[i][0]+1; j++){
				for(int k=1; k < info[0]+1; k++){
					if(info[k]==member[i][j]){
						count++;
					}
				}
			}
			if(count == info[0]){
				if(flg == 0){
					hannin = i+1;
					flg = 1;
				}else{
					hannin = -1;
					break;
				}
			}
		}
		printf("%d\n",hannin);	
	}
}

Measured memory_bytes: 3244
from collections import Counter
from scipy.misc import comb

N=int(input())
a=list(map(int,input().split()))
sli=[0]
tmp=0
for i in range(N):
    tmp+=a[i]
    sli.append(tmp)
c=Counter(sli).most_common()
ans=0
for z,x in c:
    ans+=comb(x,2,exact=True)
print(ans)

Measured memory_bytes: 58432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  vector<int> num;
  int n,m,l,i;
  int max;

  while(1){
    cin>>n>>m;
    if(n==0&&m==0) break;
    max=0;
    
    num.push_back(0);
    
    for(i=0;i<n;i++){
      cin>>l;
      num.push_back(l);
    }
    for(i=0;i<m;i++){
      cin>>l;
      num.push_back(l);
    }
    sort(num.begin(),num.end());

    for(i=0;i<(int)num.size()-1;i++)
      if(num[i+1]-num[i]>max) max=num[i+1]-num[i];
    
    printf("%d\n",max);
    num.clear();
    max=0;
  }
  return 0;
}

Measured memory_bytes: 1036
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 1000000

signed main(){   

    string A;

    cin>>A;

    if(A[0]>='A'&&A[0]<='Z'){
        cout<<"A"<<endl;
    }
    else{
        cout<<"a"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3120
def to_radian(degree)
  degree * Math::PI / 180
end

a, b, h, m = gets.split.map(&:to_i)

l = 360.0 * (h * 60 + m) / 720
s = 360.0 * m / 60
d = l - s

puts Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(to_radian(d)))


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

int main(){
  int A,B,C;
  cin >> A >> B;
  int count=0;
  C = 0;
  
  if(B==1){
    cout << "0" << endl;
    return 0;
  }
  
  for(int i=1;i<30;i++){
    C = A*i-(i-1);
    count++;
    if(C >= B){
      cout << count << endl;
      return 0;
    }
  }
}

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

int main(){
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    if(a[0]==5&&a[1]==5&&a[2]==7) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true){

			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if(op.equals("?"))break;

			int ans = 0;

			switch(op){
			case "+":
				ans = a+b;
				break;
			case "-":
				ans = a-b;
				break;
			case "*":
				ans = a*b;
				break;
			case "/":
				ans = a/b;
				break;
			}

			System.out.println(ans);
		}
	}
}




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

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

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

void alpha(){

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

	ll arr[n];
	loop(i,0,n) cin>>arr[i];

	sort(arr, arr+n, greater<ll>());

	ll ans=0;

	loop(i,0,n){
		if(i+1<=k) continue;
		else ans+=arr[i];
	}
	
	cout<<ans<<endl;

	return;

}

int main(){

	ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);


    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    int b;
    cin>>b;
    a[0]=b;
    int i;
    for(i=1;i<=2;i++)
    {
        a[i]=b*a[i-1];
    }
    cout<<a[0]+a[1]+a[2]<<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n;
int a[1000100];
int mod2(int n,int k){
	k=(k|(n-k));
	if(n==k)
		return 3;
	return 0;
}
void End(int pp){
	printf("%d\n",pp);
	exit(0);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%1d",&a[i]);
		a[i]--;
	}
	int x=0,y=0;
	for(int i=0;i<n;i++){
		x^=(mod2(n-1,i)&a[i]);
		y|=a[i];
	}
	if(x&1)
		End(1);
	else if(y&1)
		End(0);
	else if(x&2)
		End(2);
	else
		End(0);
	return 0;
}


Measured memory_bytes: 4096
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(l[k-1])


Measured memory_bytes: 61800
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////

struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;

graph g(100001);
vi v(100001);
vi ck(100001);

bool calc(int u,int cost){
    if(ck[u]==1)return true;
    if(cost%2 == 0)v[u]=1;
    ck[u]=1;
    rep(i,g[u].size()){
        calc(g[u][i].to,cost+g[u][i].cost);
    }
    return true;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n; cin>>n;
    ll u1,u2,w;
    rep(i,n-1){
        cin>>u1>>u2>>w;
        g[u1].pb(edge(u2,w));
        g[u2].pb(edge(u1,w));
    }
    rep(i,n+1){v[i]=0; ck[i]=0;}
    v[1]=1; //ck[0]=1;
    calc(1,0);
    rep(i,n){
        cout<<v[i+1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 8064
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

#define rep(i,j) for(int i=0;i<(int)(j);++i)
typedef long long qword;
const int maxn = 1e5 + 10;
qword a[maxn];



inline void run(int N, int k) {
    rep(i,N) {
        cin >> a[i];
    }
    qword ans = 0x7fffffffff;
    for (int i = 0; i < N - k + 1; ++ i) {
        qword x = a[i], y = a[i + k - 1];
        if (1ll * x * y < 0) {
            ans = min(ans, 2 * abs(x) + abs(y));
            ans = min(ans, 2 * abs(y) + abs(x));
        } else {
            ans = min(ans, max(abs(x), abs(y)));
        }
    }
    cout << ans << endl;
}

int main() {
    int N, k;
    while (cin >> N >> k) {
        run(N, k);
      	return 0;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,X;
  cin>>A>>B>>X;
  int Y;
  Y = A+B;
  if(A>X){
      cout<<"NO"<<endl;
  }else if(Y<X){
      cout<<"NO"<<endl;
  }else{
       cout<<"YES"<<endl;
  }
        
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;

	int N, M;
	ArrayList<Integer>[] link;
	int ans[];
	int cost[];
	void doIt() {
		N = sc.nextInt();
		M = sc.nextInt();
		link = new ArrayList[N];
		ans = new int[N];
		Arrays.fill(ans, N + 1);
		cost = new int[N];
		Arrays.fill(cost, MAX);
		for(int i = 0; i < N; i++)link[i] = new ArrayList<>();
		for(int i = 0; i < M; i++) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			link[A].add(B);
			link[B].add(A);
		}
		PriorityQueue<Edge> pq = new PriorityQueue<>();
		pq.add(new Edge(0, 0, 0));
		while(!pq.isEmpty()) {
			
			Edge e = pq.poll();
			if(cost[e.to] <= e.cost)continue;
			cost[e.to] = e.cost;
			ans[e.to] = e.cur;
			for(int i : link[e.to]) {
				pq.add(new Edge(e.to, i, e.cost + 1));
			}
		}
		for(int i = 0; i < N; i++) {
			if(ans[i] >= N) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
		for(int i = 1; i < N; i++) {
			System.out.println(ans[i] + 1);
		}
		
		
		
	}
	class Edge implements Comparable<Edge>{
		int cur, to;
		int cost;
		Edge(int cu, int t, int c){
			cur = cu; to = t; cost = c;
		}
		
		@Override
		public int compareTo(Edge arg0) {
			return this.cost - arg0.cost;
		}
		
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 79508
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    if H % 3 == 0 or W % 3 == 0:
        print(0)
        return

    ans = INF
    for i in range(2):
        if i == 1:
            H, W = W, H

        for h in range(1, H):
            a1 = h * W

            if (H - h) % 2 == 0:
                a2 = (H - h) // 2 * W
                tmp = abs(a1 - a2)
                if tmp < ans:
                    ans = tmp
            else:
                h2 = (H - h) // 2
                a2 = h2 * W
                a3 = (h2 + 1) * W
                tmp = abs(a2 - a3)
                if tmp < ans:
                    ans = tmp

            if W % 2 == 0:
                a2 = (H - h) * (W // 2)
                tmp = abs(a1 - a2)
                if tmp < ans:
                    ans = tmp
            else:
                w = W // 2
                a2 = (w + 1) * (H - h)
                a3 = w * (H - h)
                M = max(a1, a2, a3)
                m = min(a1, a2, a3)
                tmp = abs(M - m)
                if tmp < ans:
                    ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
//const ll MOD = 1000000007ll;
const ll MOD = 998244353ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう

int main(){
    int a,b;
    std::cin >> a>>b;
    if(a<=b)std::cout << a<< std::endl;
    else std::cout << a-1 << std::endl;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
int n,m;
int main()
{
	cin >> n >> m;
	long long ans=0;
	for(int i=m+1; i<=n; i++)
	{
		ans+=(i-m)*(n/i)+max(0,(n%i)-m+1);
		if(!m) ans--;
		//cout << i << ' ' << (i-m)*(n/i)+max(0,(n%i)-m+1)<<'\n';
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3568
A,B,K=map(int,input().split())
for i in range(K):
    if i%2==0:
        if A%2==1:
            A-=1
        A,B=A//2,B+A//2
    else:
        if B%2==1:
            B-=1
        A,B=A+B//2,B//2
print(A,B)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
    int k;cin>>k;
    if(k%2==0||k%5==0)
    p(-1);
    else
    {   ll ch=7;
        ll tp;
        ll count=1;
        while(true)
        {   if(ch%k==0)
            break;
            ch=ch%k;
            ch=ch*10+7;
            count++;
            if(count>=1e8)
            {count=-1;break;}
        }
        p(count);
    }
    
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10636
N = int(input())
H = list(map(int, input().split()))
kekka='Yes'
maxx = 0
for i in range(N):
    if H[i] < maxx -1:
        kekka = 'No'
        break
    else:
        maxx = max(H[i],maxx)
print(kekka)

Measured memory_bytes: 14396
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
double max=-1,min=-1,n;
while(scanf("%lf",&n)!=EOF){
if(n>max||max==-1){
max=n;
}
if(n<min||min==-1){
min=n;
}
}
cout<<max-min<<endl;
}

Measured memory_bytes: 1284
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	n := 0
	sc := bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}
	A := make([]int, n)
	for i := 0; i < n; i++ {
		if !sc.Scan() {
			break
		}
		A[i], _ = strconv.Atoi(sc.Text())
	}

	result, G, count := shellSort(A, n)
	fmt.Println(len(G))
	fmt.Println(String(G))
	fmt.Println(count)
	for _, v := range result {
		fmt.Println(v)
	}
}

func insertionSort(A []int, n, g int) ([]int, int) {
	cnt := 0
	for i := g; i < n; i++ {
		v := A[i]
		j := i - g
		for j >= 0 && A[j] > v {
			A[j+g] = A[j]
			j = j - g
			cnt++
		}
		A[j+g] = v
	}
	return A, cnt
}

func shellSort(A []int, n int) ([]int, []int, int) {
	cnt, tmp := 0, 0
	var G []int

	for h := 1; h <= n; {
		G = append(G, 0)
		copy(G[1:], G[0:])
		G[0] = h
		h = 3*h + 1
	}

	for i := 0; i < len(G); i++ {
		A, tmp = insertionSort(A, n, G[i])
		cnt += tmp
	}
	return A, G, cnt
}

func String(A []int) string {
	return strings.Trim(fmt.Sprint(A), "[]")
}



Measured memory_bytes: 17456
inp_num=input().split()
taka_hp=int(inp_num[0])
taka_atr=int(inp_num[1])
ao_hp=int(inp_num[2])
ao_atr=int(inp_num[3])

while taka_hp >=0 or ao_hp >=0:
    #taka攻撃
    ao_hp= ao_hp - taka_atr
    if ao_hp <=0:
        print("Yes")
        break
    #ao攻撃
    taka_hp= taka_hp - ao_atr
    if taka_hp <=0:
        print("No")
        break

Measured memory_bytes: 9124
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

dic = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}
B = sr()
answer = dic[B]
print(answer)
# 04

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll mod=1000000007;

bool sosu(ll a){
  for(ll i=2;i*i<=a;i++){
    if(a%i==0) return 0;
    // cout<<i<<endl;
  }
  return 1;
}

int main(){
  ll x; cin>>x;

  while(1){
    // cout<<"x "<<x<<endl;
    bool c=sosu(x);
    if(c||x==2){
      cout<<x<<endl;
      return 0;
    }
    x++;
    // if(x==30)
    // break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k,cnt1=0,cnt2=0;
	cin>>n>>k;
	cnt1=n/k;
	if (k%2==0 && n>=(k/2)) cnt2=(n-k/2)/k+1;
	cout<<cnt1*cnt1*cnt1+cnt2*cnt2*cnt2;
	return 0;
}

Measured memory_bytes: 256
/**
    AUTHOR:JUNSH
    TIME:19/5/25
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define rev(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const ll inf=0x3f3f3f3f;
ll n,m;
const ll maxn=15;
ll a[maxn];
ll st[maxn];
ll solve(ll pos,ll bit){
    if(pos>n){
        for(int i=1;i<=m;++i){
            ll tmp=bit&a[i];
            ll res=0;
            while(tmp>0){
                if(tmp&1)res++;
                tmp/=2;
            }
            if((res&1)!=st[i])
                return 0;
        }
        return 1;
    }
    return solve(pos+1,bit)+solve(pos+1,bit|(1<<pos));
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(ll i=1;i<=m;++i){
        ll k;
        cin>>k;
        ll bit=0;
        ll tmp;
        for(ll j=1;j<=k;++j){
            cin>>tmp;
            bit|=(1<<tmp);
        }
        a[i]=bit;
    }
    for(ll i=1;i<=m;++i){
        cin>>st[i];
    }
    ll ans=solve(1,0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long ans = 0;
    for (int i = 0; i < n; i++){
        long long anum = (lower_bound(a.begin(), a.end(), b[i]) - a.begin());
        long long cnum = (n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin()));
        ans += anum * cnum;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1536
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  double n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  OUT(ceil(a/b));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    vector<pair<ll,ll>> m;

    ll N,M; cin >> N >> M;
    for(int i = 0;i < N;i++){
      ll A,B; cin >> A >> B;
      m.push_back(make_pair(A,B));
    }

    sort(m.begin(),m.end());


    ll ans = 0;

    ll cnt = 0;

    for(int i = 0;i < N;i++){
      if(cnt + m[i].second <= M){
        cnt += m[i].second;
        ans += m[i].first * m[i].second;
      }
      else{
        ans += (M - cnt) * m[i].first;
        break;
      }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define pi 3.14159265358979323846264338327950L
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    int n,k,d;
    cin>>n>>k;
    int a[n+1];
    FOR(i,1,n+1)
    {
        a[i]=0;
    }
    FOR(i,0,k)
    {
        cin>>d;
        for(int j=1;j<=d;j++)
        {
            int x;
            cin>>x;
            a[x]=1;
        }
    }
    int count_=0;
    FOR(i,1,n+1)
    {
        if(a[i]==0)
            count_++;
    }
    cout<<count_<<endl;
    return 0;
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll A;
    string B;
    cin >> A >> B;
    ll C = 0;
    rep(i,B.size()) {
        if (B[i]=='.') continue;
        C = C*10 + (ll) B[i] - '0';
    }
    ll ans = A*C;
    ans /=100;

    cout << ans << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define pb push_back 
#define ff first 
#define ss second
#define all(c) c.begin(), c.end()
#define sz(z) (int)z.size()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; i--)
//Debugging tools 
#define debug(v) cout<<#v<<endl;for(ll i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define debugn(v,n) cout<<#v<<endl;for(ll i=0; i<n; i++) cout<<v[i]<<" "; cout<<endl;
#define deb(sum) cout<<#sum<<" = "<<sum<<endl;
//Predefined values
#define INF (ll)1e18
#define endl "\n"
#define pi 3.142857142857143


int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.in","r",stdin);
        freopen("output.in","w",stdout);
    #endif

    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        map<string, int>d;
        while(n--){
            string s;
            cin>>s;
            d[s]++;
        }
        cout<<"AC x "<<d["AC"]<<endl;
        cout<<"WA x "<<d["WA"]<<endl;
        cout<<"TLE x "<<d["TLE"]<<endl;
        cout<<"RE x "<<d["RE"]<<endl;
    }
  return 0;
} 

















Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
const int N = 100010;
 
int a[N];
 
int main()
{	int n;
	scanf("%d", &n);
	int Max = 0;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n, greater<int>());
	int p = 1;
	while (p <= n && p <= a[p])
		p++;
	p--;
	int x = 1;
	while (p+x <= n && a[p+x] == p)
		x++;
	x--;
	if (((a[p]-p) & 1) || (x & 1))
		puts("First");
	else
		puts("Second");
	return 0;
}

Measured memory_bytes: 640