akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
int n,m,a[maxn],fa[maxn],cnt[maxn],ans;
ll sum[maxn];
struct edge{
	int u,v,w;
	bool operator<(const edge &e)const{
		return w<e.w;
	}
}e[maxn];
inline int read(){
	int x=0,f=0;
	char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int getfa(int x){
	return x==fa[x]?x:fa[x]=getfa(fa[x]);
}
int main(){
	n=read();m=read();
	FOR(i,1,n) a[i]=read();
	FOR(i,1,m) e[i].u=read(),e[i].v=read(),e[i].w=read();
	sort(e+1,e+m+1);
	FOR(i,1,n) sum[i]=a[i],fa[i]=i;
	FOR(i,1,m){
		int u=e[i].u,v=e[i].v;
		int uf=getfa(u),vf=getfa(v);
		if(uf==vf) cnt[uf]++;
		else{
			sum[uf]+=sum[vf];
			cnt[uf]+=cnt[vf]+1;
			fa[vf]=uf;
		}
		if(e[i].w<=sum[uf]){
			ans+=cnt[uf];
			cnt[uf]=0;
		}
	}
	printf("%d\n",m-ans);
}

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

int main() {
   int N;
   char S[N];
   int count = 0;

   scanf("%d", &N);
   scanf("%s", S);
   for(int i = 0; i < N; i++) {
      if(S[i] =='A') {
         if(S[i+1] == 'B') {
            if(S[i+2] == 'C') {
               count++;
            }
         }
      }
   }
   printf("%d", count);
   return 0;
}


Measured memory_bytes: 1744
#include<stdio.h>
int main(void) {

int h, r;

scanf("%d", &h);
scanf("%d", &r);

if(h + r ==0) {

printf("0\n");
} else if(h + r > 0) {

printf("1\n");
} else if(h + r < 0) {

printf("-1\n");
}


return 0;
}

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

public class Main {	
	private static void solve(){
		//Implement solution here.
		int A = ni();
		int B = ni();
		int C = ni();
		int K = ni();
		int result = 0;
		if(K <= A) {
			result += K;
			K = 0;
		} else {
			result += A;
			K -= A;
		}
		
		if(K > 0) {
			if(K <= B) {
				K = 0;
			} else {
				K -= B;
			}
		}
		
		if(K > 0) {
			result -= K;
		}
		
		System.out.println(result);

	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25332
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> b(n - 1);
    rep(i,n - 1){
        cin >> b[i];
    }
    int out = 0;
    for(int i = 0; i < n - 2; i++){
        out += min(b[i],b[i + 1]);
    }
    out += b[0] + b[n - 2];
    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

A,B = map(int,input().split(' '))

if A > B:
  if (A - B) % 2 == 0:
    print(A - int((A - B) / 2))
  else:
    print('IMPOSSIBLE')
else:
  if (B - A) % 2 == 0:
    print(B - int((B - A) / 2))
  else:
    print('IMPOSSIBLE')  

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

int main()
{
 int count=0,L,R,d;
  cin>>L>>R>>d;
  
  for(int i=L;i<=R;i++)
  {
    if(i%d==0)
      count++;
  }
  cout<<count;
}

Measured memory_bytes: 3168
// ayy
// ' lamo
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld; //CARE
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
const ld eps=1e-8;
const int inf=1e9+99;
const ll linf=1e18+99;
const int P=1e9+7;













int32_t main() {
	int n,m,k; cin>>n>>m>>k;
	for(int x=0;x<=n;x++) for(int y=0;y<=m;y++) {
		int z=x*m + y*n - 2*x*y;
		if(z==k) return cout<<"Yes"<<endl,0;
	}
	cout<<"No"<<endl;
}













Measured memory_bytes: 256
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = int(input())
  nums = []
  for i in range(5):
    nums.append(int(input()))
  
  min_num = min(nums)
  print(math.ceil(n/min_num)+4)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

int main() {
  int n, f = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    if(a[i] % 2 == 0) {
      if(!(a[i] % 3 == 0 || a[i] % 5 == 0)) {
        f = 1;
        break;
      }
    }
  }
  if(f == 1) {
    cout << "DENIED";
  } else {
    cout << "APPROVED";
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=200001;
int n;
int a[MAXN],b[MAXN],A[MAXN],B[MAXN],ans=0;
inline bool CMP(int x,int y){
	return x<y;
}
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i) b[i]=read();
	for(int w=0;w<=28;++w){
		for(int i=1;i<=n;++i){
			A[i]=a[i]&((1<<(w+1))-1);
			B[i]=b[i]&((1<<(w+1))-1);
		}
		sort(B+1,B+n+1,CMP);
		for(int i=1;i<=n;++i){
			int l1=lower_bound(B+1,B+n+1,(1<<w)-A[i])-B;
			int r1=lower_bound(B+1,B+n+1,(1<<(w+1))-A[i])-B-1;
			int l2=lower_bound(B+1,B+n+1,3*(1<<w)-A[i])-B;
			int r2=lower_bound(B+1,B+n+1,(1<<(w+2))-A[i])-B-1;
			if((r1-l1+r2-l2+2)&1) ans^=(1<<w);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3328
PROGRAM A
      
      INTEGER N, Ans
      READ(*,*) N
      IF(mod(N,2).EQ.1)THEN
         Ans = (N + 1) / 2
      ELSE IF(mod(N,2).EQ.0)THEN
         Ans = N / 2
      END IF
      WRITE(*,*) Ans
      
      END

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (long(i) = 0; (i) < (n); (i)++)
#define sort(s) sort(s.begin(), s.end(), greater<int>())
#define ll long long int
using namespace std;

ll gcd(ll u, ll v) {
  while (v != 0) {
    ll r = u % v;
    u = v;
    v = r;
  }
  return u;
}
int main() {
  ll n, x;
  cin >> n >> x;
  cout << 3 * (n - gcd(n, x)) << endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int n = 1;
  for (int i=0 ; i<3 ; i++){
    if (s.at(i) == s.at(i+1)){
      n = 0;
      break;
    }
  }
  
  if (n == 1)
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;
}

Measured memory_bytes: 3584
/// Date: 07-April-2018
/// MD:NUR ALAM
#include "bits/stdc++.h"
using namespace std;
int main(){

  int a=0,b=0,c=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else if(s[i]=='c') c++;
  }
  if(a>1 || b>1 || c>1) cout<<"No";
  else cout<<"Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define FOR(i,m,M) for(int i = m;i<M;i++)
 
int main()
{
	int N;
	bool flag = false;
	cin >> N;
	FOR(i, 1, 10)
	{
		if (N % i == 0 && N/i <10)
		{
			flag = true;
			break;
		}
 
	}
	if (flag)
		cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

////////////////いろいろあるよ//////////////////////////////////
int main(){
	ll N;
 	cin >> N;
  	char data[N];
  	int count = 0;
  	REP(i,N){
      	cin >> data[i];
      	if(data[i] == 'R')count++;
    }
  
  	int ans = 0;
  	REP(i,count){
      	if(data[i] == 'W')ans++;
    }
  
  	cout << ans << endl;
  
}


Measured memory_bytes: 3828
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N):
        u, k, *vc = (int(i) for i in input().split())
        for i in range(0, len(vc), 2):
            G[u].append((vc[i], vc[i+1]))
    d = [[(1 << 63)-1, i] for i in range(N)]
    from heapq import heapify, heappop, heappush

    def dijkstra(s):
        d[s][0] = 0
        que = [(d[s][0], s)]
        heapify(que)
        finished = set()
        while len(finished) < N:
            u = heappop(que)
            while u[1] in finished:
                u = heappop(que)
            for v, c in G[u[1]]:
                if v in finished:
                    continue
                if d[v][0] > u[0] + c:
                    d[v][0] = u[0] + c
                    heappush(que, (d[v][0], v))
            finished.add(u[1])
    dijkstra(0)
    for i, val in enumerate(d):
        print(i, val[0])


if __name__ == '__main__':
    main()



Measured memory_bytes: 6160
s=input()
l=[0 for i in range(len(s))]
r=[0 for i in range(len(s))]
ans=[0 for i in range(len(s))]
nl=0
nr=0
for i in range(len(s)):
  if s[i]=="R":
    nr+=1
    r[i]=nr
  else:
    nr=0
for i in range(len(s)):
  if s[-1*i]=="L":
    nl+=1
    l[-1*i]=nl
  else:
    nl=0
for i in range(len(s)):
  if r[i]==0:
    if r[i-1]%2==0:
      ans[i-1]+=r[i-1]//2
      ans[i]+=r[i-1]//2
    else:
      ans[i-1]+=r[i-1]//2+1
      ans[i]+=r[i-1]//2
  if l[-1*i]==0:
    if l[-1*i+1]%2==0:
      ans[-1*i+1]+=l[-1*i+1]//2
      ans[-1*i]+=l[-1*i+1]//2
    else:
      ans[-1*i+1]+=l[-1*i+1]//2+1
      ans[-1*i]+=l[-1*i+1]//2
for i in range(len(s)):
  print(ans[i])


Measured memory_bytes: 9584
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  char w[11];
  char t[1001];
  int i = 0;
  int count = 0;
  char end[] = "END_OF_TEXT";
  
  scanf("%s", w);
 
  while(1) {
  scanf("%s", t);

  if(strcmp(t, end) == 0)
    break;
  
    i = 0;
    while(t[i]) {
      t[i] = tolower(t[i]);
      i++;
    }

    if(strcmp(w, t) == 0)
      count++;
  }

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


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = 0;

  vector<ll> b(N, 0);
  rep(i, N) b[a[i]]++;
  bool ok = true;
  //  rep(i, N) cout << b[i] << " " ; cout << endl;
  if(N%2==0) {
    rep(i, N) {
      if(b[i] != i%2*2) ok = false;
    }
  } else {
    if(b[0] != 1) ok = false;
    for(ll i = 1; i < N; i++) {
      if(b[i] != ((i+1)%2)*2) ok = false;
    }
  }
  if(ok) {
    ans = 1;
    rep(i, N/2) {
      ans *=2;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4844
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int d, n, m;
    while(cin >> d >> n >> m, d) {
        vector<ll> D(n), K(m);
        rep(i, n - 1) { cin >> D[i + 1]; }
        rep(i, m) cin >> K[i];
        sort(All(D));
        ll res = 0;
        rep(i, m) {
            auto itr = lower_bound(All(D), K[i]);
            int idx = distance(D.begin(), itr);
            ll tmp = 1e9 + 10;
            if(itr != D.end())
                tmp = D[idx] - K[i];
            if(idx - 1 >= 0)
                tmp = min(tmp, K[i] - D[idx - 1]);
            tmp = min(tmp, d - K[i]);
            res += tmp;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3512
#pragma GCC optimize("O2")

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

#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define endl "\n"
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
typedef long long ll;
#define mk(arr, n, type) type *arr = new type[n]
const int mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

#define watch(x) cout << (#x) << " is : " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"

void b_v_r()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    b_v_r();

    ll k;
    cin >> k;

    if (k % 2 == 0 || k % 5 == 0)
    {
        // If k is even or multiple of 5
        cout << "-1" << endl;
        return 0;
    }
    else
    {
        ll num = 7;
        ll cnt = 1;

        while (true)
        {
            if (num % k == 0)
            {
                // if k divided 7,77,777,7777,...
                cout << cnt << endl;
                break;
            }

            if (cnt > k)
            {
                // The Answer cant be Greater than the Number
                cout << "-1" << endl;
                break;
            }
            // The Most Important Step
            // To make Sure that num does not exceed its limit
            
            num = ((num % k) * 10) + 7;
            // cout << num << endl;
            cnt++;
        }
    }

    return 0;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        ll X, K, D;
        cin >>X >>K >>D;
        if (X<0)
                X=-X;
        if (X/D>=K) {
                cout <<X-K*D <<endl;
                return 0;
        }
        ll N=X/D;
        K -=N;
        ll DD=X%D;
        if (0==K%2)
                cout <<DD <<endl;
        else
                cout <<D-DD <<endl;
        return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int w, h, x, y; cin >> w >> h >> x >> y;
    double ans = (double)w * h / 2.0;
    cout << fixed << setprecision(10) <<  ans << endl;
    if(2*x == w && 2*y == h) cout << '1' << endl;
    else cout << '0' << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<stack>
#include<deque>
#include<queue>
#include<cmath>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<algorithm>
#define inf 2139062143
#define re register
#define ll long long
#define ull unsigned long long
#define lowbit(x) x&-x
#define Flj(i,a,b) for(int i=(a);i;i=(b))
#define Fze(i,a,b) for(int i=(a);i<(b);i++)
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Fer(i,a,b) for(int i=(a);i>=(b);i--)
#define Fer1(i,a,b) for(int i=(a);i>b;i--)
#define Dfor(i,a,b,k) for(double i=(a);i<(b);i+=k)
#define Qmax priority_queue
#define Qmin priority_queue<int,vector<int>,greater<int> >
using namespace std;
int read(){
	int x=0,f=1;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 x*f;
}
int n, A, B;
int main(){
	n = read(); A = read(); B = read();
	printf("%d", min(n * A, B));
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 300005

ll N;
ll A[SIZE],SUM[SIZE];

int main(){

	scanf("%lld",&N);

	for(int i = 0; i < N; i++){

		A[i] = 0;
	}

	ll tmp;

	for(int i = 0; i < N; i++){

		scanf("%lld",&tmp);
		A[tmp-1]++;
	}
	sort(A,A+N);

	SUM[0] = 0;
	for(int i = 0; i < N; i++){

		SUM[i+1] = SUM[i]+A[i];
	}

	for(ll k = 1; k <= N; k++){
		ll left = 0,right = N/k+1,mid; //left:OK right:NG

		while(left+1 < right){
			mid = (left+right)/2; //仮の答え

			ll loc = lower_bound(A,A+N,mid)-A; //mid以上のものはmidにする(最大でもmidまでしか取れないため)
			ll sum = mid*(N-loc)+SUM[loc];

			if(sum >= mid*k){

				left = mid;

			}else{

				right = mid;
			}
		}
		printf("%lld\n",left);
	}

	return 0;
}


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

int main(int argc, char *argv[]) {
  string S;
  cin >> S;
  if(S.size() == 2) {
    cout << S << endl;
  } else {
    reverse(S.begin(), S.end());
    cout << S << endl;
  }
  return 0;
}


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

int main(){
  int n,m; cin >> n >> m;
  priority_queue<ll> a;
  for(int i=0; i<n; i++){
    ll h; cin >> h;
    a.push(h);
  }
  for(int j=0; j<m; j++){
    ll k;
    k = a.top()/2;
    a.pop();
    a.push(k);
  }ll ans =0;
  for(int l =0; l<n; l++){
    ans+=a.top();
    a.pop();
  }
  cout << ans << endl;

}


Measured memory_bytes: 1400
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
	
	Scanner in = new Scanner(System.in);
	
	int a=0;
	int b,c;
	
	
	a = in.nextInt();	
	b= in.nextInt();
	c= in.nextInt();
	int[] aa={a,b,c};
	Arrays.sort(aa);
	System.out.println(aa[0]+aa[1]+aa[2]*10);
	}	
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */



template<class T>
std::istream& operator>>(std::istream& is, T& X){
    assert(!X.empty());
    for (int i = 0; i < X.size(); ++i) {
        is >> X[i];
    } // end i
}

ll N, L;


void solve(istream &cin) {
    L = 0; N = 0;
    cin >> L >>  N;
    if(!cin) return;
    vector<ll> X(N);
    cin >> X;
    vector<ll> sumL(N+1), sumR(N+1);
    for (int i = 1; i <= N; ++i) {
        sumL[i] = sumL[i-1] + X[i-1];
        sumR[i] = sumR[i-1] + (L - X[N-i]);
    } // end i

    ll ans = 0;
    for (int k = 1; k <= N; ++k) {
        // <--
        ll R = N - k;
        ll c;
        ll m = R / 2 + k;
        if(R % 2 == 0){
            c = 2*(sumL[m] - sumL[k-1]) - X[m-1]
                    + 2*(sumR[R/2]);
        }
        else{
            c = 2*(sumL[m] - sumL[k-1])
                    + 2*(sumR[R/2]) + (sumR[R/2+1] - sumR[R/2]);
        }
        ans = max(ans, c);
    } // end k


    for (int k = 1; k <= N; ++k) {
        // -->
        ll R = N - k;
        ll c;
        ll m = R / 2 + k;
        if(R % 2 == 0){
            c = 2 * sumL[R/2]
                    + 2 *(sumR[m] - sumR[k-1]) - sumR[m] + sumR[m-1];
        }
        else{
            c = 2 * sumL[R/2] + (sumL[R/2+1] - sumL[R/2])
                + 2 *(sumR[m] - sumR[k-1]) ;
        }
        ans = max(ans, c);
    } // end k

    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


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

int main(){
    ll a,b100;
    double b;
    cin>>a>>b;
    b100=b*100+0.5;
    cout<<a*b100/100<<endl;
    return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define inf 999999999
string s,sss;
int a[26];
inline int solve(char a);
int main(){
    //for(int i=0;i<26;i++)a[i]=0;
    cin>>s;
    sss="";
    int n=s.length();
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)sss+=s[i];
    //for(int i=0;i<n;i++)a[s[i]-'a']++;
    //int maxs=0;
    //for(int i=0;i<26;i++){
    //    if(maxs<a[i])maxs=a[i];
    //}
    char t;
    int ans=inf;
    for(int i=n-1;i>=0;i--){
        ans=min(ans,solve(s[i]));
    }
    cout<<ans<<endl;
    return 0;
}

inline int solve(char a){
    int res=0;
    string ss="";
    for(int i=0;i<sss.length();i++)ss+=sss[i];
    while(1){
        string t="";
        //cout<<"cont="<<res<<"ss="<<ss<<endl;
        if(ss=="")return res;
        for(int i=0;i<ss.length();i++)t+=ss[i];
        for(int i=1;i<t.length();i++){
            if(t[i]==t[i-1]){
                if(i==ss.length()-1){
                    return res;
                }
            }else break;
        }
        res++;
        ss="";
        for(int i=0;i<t.length()-1;i++){
            if(t[i]==a || t[i+1]==a){
                ss+=a;
            }else ss+=t[i];
        }
    }
}

Measured memory_bytes: 256
str1 = input()
str2 = input()
str3 = input()

A = str1.split(" ")
B = str2.split(" ")
C = int(str3)
res = ""

# A：追いかける。鬼。
# B：逃げる。追われる。
if int(A[1]) <= int(B[1]):
    res = "NO"
else:
    # 距離差
    diff = abs(int(B[0]) - int(A[0]))
#    print(diff)    
    # 速度差
    speedDiff = abs(int(A[1]) - int(B[1]))
#    print(speedDiff)
    if speedDiff * C < diff:
        res = "NO"
    else:
        res = "YES"


print(res)

Measured memory_bytes: 9108
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, R; cin >> N >> R;
    if (N < 10) {
        cout << R + 100 * (10 - N) << endl;
    } else {
        cout << R << endl;
    }
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

    for(int i=0;i<n-2;i++)
      sum+=s[i+1];

    cout << sum/(n-2) << endl;
  }
  return 0;
}

Measured memory_bytes: 3032
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int a[200010], aa[200010], b[200010], bb[200010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) cin >> a[i], aa[i]=a[i];
  REP(i, n) cin >> b[i], bb[i]=b[i];

  int ret = 0;
  REP(i, 29) {
    int m = 1LL<<i;
    REP(j, n) a[j] = aa[j]%(2*m), b[j] = bb[j]%(2*m);
    sort(b, b+n);
    int num = 0;
    // cout << "i:" << i << " " << m << " " << num << endl;
    REP(j, n) {
      // [m-a[j], 2*m-a[j])
      num += lower_bound(b, b+n, 2*m-a[j]) - lower_bound(b, b+n, m-a[j]);
      // cout << lower_bound(b, b+n, 2*m-a[j])-b << " " << lower_bound(b, b+n, m-a[j])-b << endl;
      // cout << "j:" << j << " " << num << " ";
      // [3*m-a[j], 4*m-a[j])
      num += lower_bound(b, b+n, 4*m-a[j]) - lower_bound(b, b+n, 3*m-a[j]);
      // cout << num << endl;
    }
    if(num%2) {
      ret += m;
    }
    // cout << num << "," << ret << endl;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll k; cin >> k;
	ll a,b; cin >> a >> b;
	REP(i,a,b+1){
		if(i%k==0){
			puts("OK");
			return 0;
		}
	}
	puts("NG");
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))

before_turn = []
for i in reversed(A[1::2]):
    before_turn.append(i)

for i in A[::2]:
    before_turn.append(i)


if N % 2 == 0 or N == 1:
    print(" ".join(map(str, before_turn)))
else:
    turn = before_turn[::-1]
    print(" ".join(map(str, turn)))

Measured memory_bytes: 30404
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN=205;
const int MOD=998244353;

struct point
{
    int x,y;
    point(int _x=0,int _y=0):x(_x),y(_y){}
}p[MAXN];

point operator - (const point& a,const point& b)
{
    return point(a.x-b.x,a.y-b.y);
}

int cross(const point& a,const point& b)
{
    return a.x*b.y-a.y*b.x;
}

int dot(const point& a,const point& b)
{
    return a.x*b.x+a.y*b.y;
}

LL Q_pow(LL x,LL n)
{
    LL res=1;
    while(n>0)
    {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

int main()
{
    int n;
    while(scanf("%lld",&n)!=EOF)
    {
        for(int i=1;i<=n;i++)
            scanf("%d%d",&p[i].x,&p[i].y);
        LL ans=Q_pow(2,n);
        ans=(ans-1+MOD)%MOD;
        ans=(ans-n+MOD)%MOD;
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                LL cnt=0;
                for(int k=1;k<=n;k++)
                {
                    if(cross(p[k]-p[i],p[k]-p[j])==0&&dot(p[k]-p[i],p[k]-p[j])<0)
                        ++cnt;
                }
                ans=(ans-Q_pow(2,cnt)+MOD)%MOD;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    h,w=intLine()
    s=Array{Int32,2}(h,w)
    for i in 1:h
        t=input()
        for j in 1:w
            s[i,j]=t[j]>'#'
        end
    end
    a=copy(s)
    b=copy(s)
    c=copy(s)
    d=copy(s)
    for i in 1:h
        for j in 1:w
            if j>1
                a[i,j]=-~a[i,j-1]*s[i,j]
                b[i,w-j+1]=-~b[i,w-j+2]*s[i,w-j+1]
            end
            if i>1
                c[i,j]=-~c[i-1,j]*s[i,j]
                d[h-i+1,j]=-~d[h-i+2,j]*s[h-i+1,j]
            end
        end
    end
    print(maximum(a+b+c+d)-3)
end
main()

Measured memory_bytes: 243036
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
	int n;
	while(scanf(" %d", &n) != EOF){
		long p[100], ans=0;
		for(int i=0; i<n; ++i) scanf(" %ld", &p[i]);
		sort(p,p+n);
		for(int i=0; i<n; ++i) ans+=p[i]*(n-i);
			
		printf("%ld\n", ans);		
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for(int i = 0; i < a; i++) {
        cin >> p[i];
    }
    for(int i = 0; i < b; i++) {
        cin >> q[i];
    }
    for(int i = 0; i < c; i++) {
        cin >> r[i];
    }
    sort(all(p), greater<ll>());
    sort(all(q), greater<ll>());
    for(int i = 0; i < x; i++) {
        r.push_back(p[i]);
    }
    for(int i = 0; i < y; i++) {
        r.push_back(q[i]);
    }
    sort(all(r), greater<ll>());
    ll ans = 0;
    for(int i = 0; i < x + y; i++) {
        ans += r[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6512
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, k = MI()

    li = []
    for _ in range(k):
        _ = I()
        li.append(LI())

    child = list(range(1, n + 1))

    for l in li:
        for c in l:
            if c in child:
                child.remove(c)

    print(len(child))


if __name__ == "__main__":
    main()


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

int main() {
  int N, K; cin >> N >> K;
  ll ans = K*pow(K-1, N-1);
  cout << ans << endl;
//  k*(K-1)^(N-1)
  return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  sort(all(s));
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}



struct segtree{
    static const int SEG=1<<18;
    vint dat,put;

    segtree(vint v):dat(SEG*2),put(SEG*2){
        rep(i,v.size())dat[i+SEG-1]=v[i];
        for(int i=SEG-2;i>=0;i--)dat[i]=dat[i*2+1]+dat[i*2+2];
    }

    inline void push(int k){
        if(put[k])dat[k]*=-1;
        if(k<SEG-1){
            put[k*2+1]^=put[k];
            put[k*2+2]^=put[k];
        }
        put[k]=0;
    }

    void update(int a,int b,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]^=1;
            push(k);
            return;
        }
        update(a,b,k*2+1,l,(l+r)/2);
        update(a,b,k*2+2,(l+r)/2,r);
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
    int query(int a,int b,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return 0;
        if(a<=l&&r<=b)return dat[k];
        return query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2,r);
    }

};


const int SIZE=222222;

int N,Q;
vint G[SIZE];
int tt,tin[SIZE],tout[SIZE];
char C[SIZE];
void dfs(int v,int p){
    tin[v]=tt++;

    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v);
    }
    tout[v]=tt;
}


signed main(){
    cin>>N>>Q;
    for(int i=1;i<N;i++){
        int a;cin>>a;
        a--;
        G[a].pb(i);
    }
    rep(i,N)cin>>C[i];

    dfs(0,-1);

    vint vec(N);
    rep(i,N){
        if(C[i]=='G')vec[tin[i]]=1;
        else vec[tin[i]]=-1;
    }

    segtree seg(vec);


    while(Q--){
        int v;cin>>v;
        v--;
            seg.update(tin[v],tout[v]);

        int tmp=seg.query(0,N);

        if(tmp>0){
            cout<<"broccoli"<<endl;
        }
        else{
            cout<<"cauliflower"<<endl;
        }

    }
    return 0;
}



Measured memory_bytes: 27440
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (auto& s : S) cin >> s;
  
  int bias, xa, bx, ba;
  bias = xa = bx = ba = 0;
  for (auto s : S) {
    for (int i = 0; i < s.size(); i++) {
      bias += (s.substr(i, 2) == "AB");
    }
    char c = s.front();
    char d = s.back();
    if (c == 'B' && d == 'A') ba++;
    else if (c == 'B') bx++;
    else if (d == 'A') xa++;
  }
  
  int ans = bias;
  if (ba) {
    if (bx || xa) ans += ba + min(bx, xa);
    else ans += ba - 1;
  }
  else {
    ans += min(xa, bx);
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
pair<int, int> f(int H, int W, const vector<string>& S) {
    vector<vector<int>> sum(H + W - 1, vector<int>(W + 1));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            sum[i + j][j + 1] += S[i][j] == '#';
        }
    }
    for (int i = 0; i < H + W - 1; i++) {
        for (int j = 0; j < W; j++) {
            sum[i][j + 1] += sum[i][j];
        }
    }
    int a = 0, b = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] != '#') continue;
            for (int n = 1; i - n >= 0 && j + n < W; n++) {
                if (S[i - n][j + n] != '#') continue;
                if (i - 2*n >= 0 && S[i - 2*n][j] == '#') a++;
                if (j - n >= 0 && S[i - n][j - n] == '#') a++;
                if (i + j - 2*n >= 0) {
                    int x = max(j - n + 1, 0);
                    int y = j - 1;
                    if (y >= 0) {
                        b += sum[i + j - 2*n][y + 1] - sum[i + j - 2*n][x];
                    }
                }
            }
        }
    }
    return {a, b};
}
void rotate(int &H, int &W, vector<string>& S) {
    vector<string> ans(W, string(H, '@'));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans[j][H - 1 - i] = S[i][j];
        }
    }
    swap(S, ans), swap(H, W);
}
int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); for (auto &s : S) cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < 4; i++) {
        auto p = f(H, W, S);
        a += p.first, b += p.second;
        rotate(H, W, S);
    }
    cout << a / 2 + b << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
vector<vi> res;int n,m,q;
int cnt  =0;

int main(){
    int n,k;cin>>n>>k;
    int su[n];
    rep(i,n)su[i]=0;
    rep(i,k){
        int d;cin>>d;
        rep(j,d){
            int a;cin>>a;
            a--;
            su[a]++;
        }
    }
    int ans =0;
    rep(i,n){
        if(su[i]==0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
n, m, q = gets.split.map &:to_i

abcds = q.times.map {gets.split.map &:to_i}
max = 0
seq = [1] * n
loop do
  sum = 0
  abcds.each do |abcd|
    a, b, c, d = abcd
    if seq[b-1] - seq[a-1] == c
      sum += d
    end
  end
  STDERR.puts "#{seq} : #{sum}"
  max = [max, sum].max
  
  # next
  i = n-1
  while i >= 0
    if seq[i] == m
      i -= 1
    else
      seq[i] += 1
      (i...n).each { |j| seq[j] = seq[i] }
      break
    end
  end
  if i < 0
    break
  end
end
p max


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

int main(){
  int e;
  int m;
  int x,y,z;
  int min;
  while(1){
    min = 100000000;
    cin >> e;
    if(e == 0){
      break;
    }
    for(y = 0 ; y <= 1000 ; y++){
      for(z = 0 ; z <= 100 ; z++){
	x = e - (y*y) - (z*z*z);
	m = x + y +z;
	if(min > m && x >= 0 && y >= 0 && z >= 0){
	  min = m;
	}
      }
    }
    cout << min << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
li = list(map(int, input().rstrip().split()))

counter = 0
i = 0

while li[i] % 2 == 0:
    counter += 1
    li[i] = li[i] / 2
    if i == N-1:
      i = 0
    else:
      i += 1
print(int(counter/N))

Measured memory_bytes: 3060
n,ma,mb=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*n]

memo=[[10**4 for _ in [0]*(n*10+1)] for _ in [0]*(n*10+1)]
memo[0][0]=0

for N in range(n):
    for i in range(N*10,-1,-1):
        for j in range(N*10,-1,-1):
            a,b,c=abc[N]
            memo[i+a][j+b]=min(memo[i+a][j+b],memo[i][j]+c)

m=10**4
for i in range(1,n*10):
    for j in range(1,n*10):
        if i*mb==ma*j:
            m=min(m,memo[i][j])
if m==10**4:
    print(-1)
else:
    print(m)

Measured memory_bytes: 4852
using System;
namespace AtCoder.BeginnersSelections
{
    class Test
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());

            int amari = N % 500;
            if (amari <= A)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
long long a[100010];

int main() {
    int n, i;
    scanf("%d",&n);
    for(i=0;i<n; i++)
    scanf("%lld",&a[i]);
    int zero=0;
    for(i=0;i<n;i++)
        if(a[i]==0)zero++;
    if(zero > 0) {
        printf("0\n");
        return 0;
    }
    long long prod=1;
    for(int i=0;i<n;i++) {
        if(a[i]<=1000000000000000000/prod) {
            prod*=a[i];
        } else {
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n",prod);
}

Measured memory_bytes: 2484
# coding: utf-8
from collections import deque
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    D = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            D[i][j] = abs(j-i)
            D[j][i] = abs(j-i)
    D[X][Y] = 1
    D[Y][X] = 1
    queue = deque([[X, Y]])
    visited = [[False for _ in range(N)] for _ in range(N)]
    visited[X][Y] = True 
    while queue:
        x,y = queue.popleft()
        for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+i, y+j
            if nx < 0 or nx >= N or ny < 0 or ny >= N:
                continue
            if visited[nx][ny]:
                continue
            else:
                visited[nx][ny] = True
                D[nx][ny] = min(D[nx][ny], D[x][y]+1)
                queue.append([nx, ny])
    ans = [0 for _ in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            v = D[i][j]
            ans[v-1] += 1
    print(*ans[:-1], sep="\n")
main()

Measured memory_bytes: 147464
import sys
input = sys.stdin.readline

N, K = map(int,input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = 1e+10
for i in range(N-K+1):
    tmp = h[i+K-1]-h[i]
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 44380
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

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

	string A = S.substr(0, 4);
	int a = stoi(A);
	string B = S.substr(5, 2);
	string C = S.substr(8, 2);

	if (a <= 2018) { cout << "Heisei" << endl; }
	else if (a == 2019) {
		if (B == "01" || B == "02" || B == "03" || B == "04") { cout << "Heisei" << endl; }
		else { cout << "TBD" << endl; }
	}
	else { cout << "TBD" << endl;}
}

Measured memory_bytes: 256