akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = [0] + LIST()

A.sort()

def check(x):
    idx = bisect_left(A, x)
    if abs(x - A[idx]) < abs(x - A[idx-1]):
        return A[idx], abs(x - A[idx])
    else:
        return A[idx-1], abs(x - A[idx-1])

# 真ん中を調べる
n = A[-1]
r1, dist1 = check(n // 2)
r2, dist2 = check(ceil(n, 2))
if dist1 < dist2:
    r = r1
else:
    r = r2
print(n, r)


Measured memory_bytes: 14440
n, k, q = list(map(int, input().split()))

ns_points = [k] * n
ns_corrects = [0] * n
for i in range(q):
    ns_corrects[int(input())-1] += 1


for j in range(len(ns_points)):
    if ns_points[j] - (q - ns_corrects[j]) <= 0:
        print('No')
    else:
        print('Yes')

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

int c[9];

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

    rep(i, n) {
        int a;
        cin >> a;
        if (a >= 3200)
            c[8]++;
        else
            c[a / 400]++;
    }

    int minv = 0, maxv = 0;
    rep(i, 8) if (c[i]) minv++, maxv++;
    maxv += c[8];
    if (minv == 0) minv = 1;

    cout << minv << ' ' << maxv << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//#include <math.h>
signed main(void) 
{
    ull h;
    
    ull sum = 0;
    cin >>h;
    ull m = 1;
    
    while (true) {
        
        
        sum += m;
        m *= 2;
        h /= 2;
        if (h == 0) break;
    }
    
    
    
    cout <<sum;
    return 0;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss; scan(ss);
      Int n = ss.size();
      for(Int i = 1; i < n; ++i) {
         if( ss[i-1] == 'A' and ss[i] == 'C' ) {
            puts("Yes");
            return;
         }
      }
      puts("No");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




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

int main(){
  int N, M, numberA, numberB;
  cin >> N >> M;
  
  vector<int> count(N);
  for(int i=0; i<N; i++){
    count.at(i)=0; 
  }
  
  for(int j=0; j<M; j++){
    cin >> numberA >> numberB;
    count.at(numberA-1)++;
    count.at(numberB-1)++;
  }
  
  for(int i=0; i<N; i++){
    cout << count.at(i) << endl;
  }
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<int,int> mp;
    for(int i = 0; i < n; i++) {
        mp[a[i]]++;
    }
    int count=0;
    for(auto itr = mp.begin(); itr !=mp.end(); itr++) {
        int tmp=itr->second;
        if(tmp%2==1) count++;
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<int,pair<int,int>>;
#define MAX 200003
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int N,A,B;
  string S;
  cin>>N>>A>>B>>S;
  int count1=0,count2=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='a'){
      if(count1<A+B){
        count1++;
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }else if(S.at(i)=='b'){
      if(count1<A+B&&count2<B){
        count1++;
        count2++;
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }else{
      cout<<"No"<<endl;
    }
  }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;  

  vector<ll> a(n);
  REP(i, n)
    cin >> a[i];
  vector<ll> b = a;

  sort(a.begin(), a.end());
  decltype(a)::iterator result = unique(a.begin(), a.end());
  a.erase(result, a.end());
  if(a.size() == 1 && a[0] == 0)
    cout << "Yes" << endl;
  else if(n % 3 != 0)
    cout << "No" << endl;
  else if(a.size() == 3 && a[0] ^ a[1] == a[2]){
    ll sum = 0;
    REP(i, n)
      sum ^= b[i];
    if(sum == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else if(a.size() == 2 && a[0] == 0 && \
      accumulate(b.begin(), b.end(), 0LL) == a[1] * n / 3 * 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

const ll mod = 1e6+7;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
    // cin >> tt;
    while((tt)--){
        ll n,r; cin >> n >> r;
        if(n>=10){
            cout << r << endl;
        }else{
            cout << r+100*(10-n) << endl;
        }
    }
}



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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll t=1;
	//cin >> t;
	while(t--)
	{
		ll x,y;
		cin>>x>>y;
		ll a,b;
		a=y-2*x;
		b=4*x-y;
		if(a>=0 && b>=0 && (a%2==0) && (b%2==0))
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;

	}
	return 0;	
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    int t,j=0;
    map<int,bool> h;
    vector<int> e;
    for(t=0;t<m;t++)
    {
        int a,b;
        cin >> a >> b;
        if(a == 1)
            h[b] = 1;
        if(b == n)
            e.push_back(a);
    }
    for(t=0;t<e.size();t++)
        if(h[e[t] ])
        {
            j = 1;
            break;
        }
    if(j)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 9976
k = int(input())
s = len(input())
MOD = 10 ** 9 + 7


def mod_inv(n):
    return pow(n, MOD - 2, MOD)

total = pow(26, k + s, MOD)
tmp = pow(25, k + s, MOD)
total = (total - tmp) % MOD

for i in range(0, s-1):
    tmp = ((tmp * ((k+s) - i)) % MOD * mod_inv((i + 1) * 25)) % MOD
    total = (total - tmp) % MOD
print(total)


Measured memory_bytes: 72100
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(n, k) = in.readLine().split("\\s+").map(_.toInt)
    val hs = in.readLine.split("\\s+").map(_.toInt)

    System.out.println(
      hs.count(_ >= k)
    )
  }
}


Measured memory_bytes: 42208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
#define PI 3.14159265359


int main() {
    long double a,b,h,m;
    long double  ans , k;
    cin >> a >> b >> h >> m;
    h = (((30*h)+(0.5*m))*PI)/180;
    m = (6*m*PI)/180;
    k = abs(h-m);
    ans = sqrt((a*a)+(b*b)-2*a*b*cos(k));
    cout << setprecision(11)<< ans << endl;
    return 0;
}

Measured memory_bytes: 4172
#include<stdio.h>

#define MAXLENGTH 100

int main(void)
{
	int i, n;
	int a[MAXLENGTH];

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


Measured memory_bytes: 2056
N,X = map(int, input().split())

a,p = [1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if n==0:
        return 1 if x>=1 else 0
    if x==1:
        return 0
    elif x<=1+a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1]+1+f(n-1, x-2-a[n-1])
    
print(f(N,X))

Measured memory_bytes: 3188
def examA():
    L = LI(); L.sort()
    ans = L[0]*L[1]//2
    print(ans)
    return

def examB():
    def fun(s):
        if s%2==0:
            return s//2
        else:
            return s*3+1
    S = I()
    d = defaultdict(bool)
    d[S] = True; cur = 1
    while(True):
        cur +=1
        S = fun(S)
        if d[S]:
            break
        d[S] = True
    print(cur)
    return

def examC():
    return

def examD():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,ALPHABET, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 1e-9
alphabet = [chr(ord('a') + i) for i in range(26)]
ALPHABET = [chr(ord('A') + i) for i in range(26)]

if __name__ == '__main__':
    examB()


Measured memory_bytes: 3548
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll k(ll W,ll w[],ll v[],ll i)
{
    if(W==0||i==-1)return 0;
    if(w[i]>W)
    {
        return k(W,w,v,i-1);
    }else{
        return max(v[i]+k(W-w[i],w,v,i-1),k(W,w,v,i-1));
    }
}
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(n);din(W);
	ll w[n],v[n];
	for(ll i=0;i<n;i++)
	{
	    in(w[i]);in(v[i]);
	}
	ll k[n+1][W+1];
	for(ll i=0;i<=n;i++)
	{
	    for(ll j=0;j<=W;j++)
    	{
    	   if(i==0||j==0)
    	   {
    	       k[i][j]=0;
    	   }else if(w[i-1]>j){
    	       k[i][j]=k[i-1][j];
    	   }else{
    	       k[i][j] = max(v[i-1]+k[i-1][j-w[i-1]],k[i-1][j]);
    	   }
    	}
	}
	ll ans=k[n][W];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 79232
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
        _a: [usize;n],
    }

    let mut a: Vec<usize> = Vec::new();
    for i in 0..n {
        a.push(_a[i]-1);
    }
    let mut init = a[0];
    let mut v = init;
    let mut cnt = 0;
    let mut flag: Vec<bool> = vec![false;n+5];
    let mut pre = 1;
    loop {
        if flag[v]==false {
            flag[v] = true;
        } else {
            init = v;
            break;
        }
        cnt += 1;
        pre = v;
        v = a[v];
        if cnt==k{
            println!("{}", pre+1);
            return;
        }
    }

    let mut cnt1 = 0;
    v = init;
    for i in 0..cnt {
        v = a[v];
        cnt1 += 1;
        if v==init {
            break;
        }
    }
    let r = (k-(cnt-cnt1)) % cnt1;
    v = init;
    for i in 0..cnt+1 {
        if i==r {
            println!("{}", pre+1);
            return;
        }
        pre = v;
        v = a[v];
    }
}


Measured memory_bytes: 6780
xy = list(map(int, input().split()))
print("U"*(xy[3]-xy[1]) + "R"*(xy[2]-xy[0]) + "D"*(xy[3]-xy[1]) + "L"*(xy[2]-xy[0]+1) + "U"*(xy[3]-xy[1]+1) + "R"*(xy[2]-xy[0]+1) + "D" + "R"+ "D"*(xy[3]-xy[1]+1) + "L"*(xy[2]-xy[0]+1) + "U")

Measured memory_bytes: 9204
h, w = map(int, input().split())
s = []
for i in range(h):
  s.append(list(input()))
  
dx = [1, 0, -1, 0, 1, -1, 1, -1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      continue
    
    tmp = 0
    for k in range(8):
      ni = i + dx[k]
      nj = j + dy[k]
      
      if ni < 0 or ni >= h:
        continue
      if nj < 0 or nj >= w:
        continue
      if s[ni][nj] == "#":
        tmp += 1
    s[i][j] = str(tmp)

for i in range(h):
  print("".join(s[i]))
  

Measured memory_bytes: 9132
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=1010,MOD=1e9+7;
int a[N],b[N];
inline bool cmp(const int t1,const int t2){return t1>t2;}
int main(){
	int n=read(),m=read();
	for (int i=1;i<=n;++i) a[i]=read();
	for (int i=1;i<=m;++i) b[i]=read();
	sort(a+1,a+n+1,cmp),sort(b+1,b+m+1,cmp);
	int ta=0,tb=0,ans=1;
	for (int i=n*m;i;--i){
		int lta=ta,ltb=tb;
		while (ta<n&&a[ta+1]>=i) ++ta;
		while (tb<m&&b[tb+1]>=i) ++tb;
		if (ta-lta>1||tb-ltb>1){
			ans=0;break;
		}
		if (ta*tb<n*m-i+1){
			ans=0;break;
		}
		if (ta==lta&&tb==ltb) ans=1ll*ans*(ta*tb-(n*m-i))%MOD;
		if (ta==lta+1&&tb==ltb) ans=1ll*ans*tb%MOD;
		if (ta==lta&&tb==ltb+1) ans=1ll*ans*ta%MOD;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

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


Measured memory_bytes: 256
import java.util.*;
public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 0;
		if(s.equals("SUN")) {
			ans = 7;
		}
		if(s.equals("MON")) {
			ans = 6;
		}
		if(s.equals("TUE")) {
			ans = 5;
		}
		if(s.equals("WED")) {
			ans = 4;
		}
		if(s.equals("THU")) {
			ans = 3;
		}
		if(s.equals("FRI")) {
			ans = 2;
		}
		if(s.equals("SAT")) {
			ans = 1;
		}
		System.out.println(ans);
     }
}

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

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

vector<vector<int>> M;
vector<vector<int>> checked;
int ans;
int w, h;

void dfs(int row, int col) {
  ans++;
  checked[row][col] = 1;
  for (int i = 0; i < 4; i++) {
    int x = col + dx[i];
    int y = row + dy[i];
    if (0 <= x && x < w && 0 <= y && y < h && M[y][x] == 1 &&
        checked[y][x] == 0) {
      dfs(y, x);
    }
  }
}
int main() {
  while (cin >> w >> h) {
    if (!w && !h)
      break;

    ans = 0;
    M = vector<vector<int>>(h, vector<int>(w));
    checked = vector<vector<int>>(h, vector<int>(w, 0));

    int s_row, s_col;
    for (int i = 0; i < h; i++) {
      string line;
      cin >> line;
      for (int j = 0; j < w; j++) {
        char c = line[j];
        if (c == '.') {
          M[i][j] = 1;
        } else if (c == '#') {
          M[i][j] = 0;
        } else {
          M[i][j] = 1;
          s_row = i;
          s_col = j;
        }
      }
    }
    dfs(s_row, s_col);
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3108
import java.util.*;
import java.math.*;

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

    String min = s.length() < t.length() ? s : t;
    String max = s.length() < t.length() ? t : s;

//    char[][] cs = new char[min.length() + 1][max.length() + 1];
//    for (char[] a : cs) Arrays.fill(a, ' ');
//    for (int i = 0; i < min.length(); i++) {
//      for (int j = 0; j < max.length(); j++) {
//        if (min.charAt(i) == max.charAt(j)) {
//          cs[i + 1][j + 1] = min.charAt(i);
//        }
//      }
//    }
//    Arrays.stream(cs).map(Arrays::toString).forEach(System.out::println);


    int[][] dp = new int[min.length() + 1][max.length() + 1];
    for (int i = 1; i < min.length() + 1; i++) {
      for (int j = 1; j < max.length() + 1; j++) {
        if (min.charAt(i - 1) == max.charAt(j - 1)) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
//          dp[i][j] = Math.min(
//              dp[i - 1][j],
//              dp[i][j - 1]) +1;
        } else {
          dp[i][j] = Math.max(
              dp[i - 1][j],
              dp[i][j - 1]);
        }
      }
    }

//    Arrays.stream(dp).map(Arrays::toString).forEach(System.out::println);

    StringBuilder buf = new StringBuilder();
    int x = max.length();
    for (int i = min.length(); 0 < i; i--) {
      for (int j = x; 0 < j; j--) {
        if (min.charAt(i - 1) != max.charAt(j - 1)) {
          if (dp[i][j - 1] < dp[i][j]) {
            break;
          } else {
            continue;
          }
        }
        if (dp[i][j - 1] < dp[i][j]) {
          buf.append(min.charAt(i - 1));
          x = j - 1;
          break;
        }
      }
    }

    String ans = buf.reverse().toString();
    System.out.println(ans);
  }
}

Measured memory_bytes: 81340
n,*a=map(int,open(0))
x=0
c=[0]*30
for i in a:
  x^=i
  c[bin(i^i-1)[::-1].rfind('1')]=1
a=0
for i in range(29,-1,-1):
  if x&2**i:
    if c[i]:
      a+=1
      x^=2**i-1
    else:
      print(-1)
      break
else:
  print(a)

Measured memory_bytes: 7068
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[][] edge;
	static int[] mincost;
	static boolean[] used;
	static int n, m;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)return false;
		
		m = sc.nextInt();
		edge = new int[n][n];
		mincost = new int[n];
		used = new boolean[n];
		for(int[] format : edge)Arrays.fill(format, Integer.MAX_VALUE);
		Arrays.fill(mincost, Integer.MAX_VALUE);
		Arrays.fill(used, false);
		
		for(int i = 0; i < m; i++){
			String[] input = sc.next().split(",");
			edge[Integer.parseInt(input[0])][Integer.parseInt(input[1])] = (Integer.parseInt(input[2])-1)/100;
			edge[Integer.parseInt(input[1])][Integer.parseInt(input[0])] = (Integer.parseInt(input[2])-1)/100;
		}
		
		return true;
	}
	
	static void solve(){
		mincost[0] = 0;
		int res = 0;
		
		while(true){
			int v = -1;
			for(int i = 0; i < n; i++){
				if(!used[i] && (v == -1 || mincost[i] < mincost[v]))v = i;
			}
			
			if(v == -1)break;
			used[v] = true;
			res += mincost[v];
			
			for(int i = 0; i < n; i++){
				mincost[i] = Math.min(mincost[i], edge[v][i]);
			}
		}
		System.out.println(res);
	}

}

Measured memory_bytes: 13000
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint A, B, C, K;
int main() {
	cin >> A >> B >> C >> K;
	lint cnt = 0;
	while (A >= B) {
		B *= 2;
		cnt++;
	}
	while (B >= C) {
		C *= 2;
		cnt++;
	}
	if (cnt > K) cout << "No";
	else cout << "Yes";
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define OUT(a) cout << (a) << "\n"

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 10e9 + 7;

int main() {
    int a,b;
  	cin >> a >> b;
  	int ans = max(a+b, a-b);
  	ans = max(ans, a*b);
  	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
typedef long long ll;
int main() {
    int x[5];
    for(int i=0;i<5;i++){
        cin >> x[i];
    }
    for(int i=0;i<5;i++){
        if(x[i] == 0){
            cout << i+1 << endl;
        }
    }
    return 0;
}

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

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var t = long.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var w1 = Array.ConvertAll(line, long.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var w2 = Array.ConvertAll(line, long.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var w3 = Array.ConvertAll(line, long.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var w4 = Array.ConvertAll(line, long.Parse);
        var a = getDic(w1, w2, n, t);
        var b = getDic(w3, w4, n, t);
        var ans = getAns(a, b, t);
        Console.WriteLine(ans);
    }
    static long getAns(Dictionary<long, long> a, Dictionary<long, long> b, long t)
    {
        var ans = 0L;
        foreach (var x in a)
        {
            var w = t - x.Key;
            if (b.ContainsKey(w)) ans += x.Value * b[w];
        }
        return ans;
    }
    static Dictionary<long, long> getDic(long[] a, long[] b, int n, long t)
    {
        var d = new Dictionary<long, long>();
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
            {
                var w = a[i] + b[j];
                if (w < t)
                {
                    if (d.ContainsKey(w)) d[w]++;
                    else d[w] = 1;
                }
            }
        return d;
    }
}




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

/*
obv first would be greatest
always best to expand the biggest
note that *strictly less* is the important part

can we just do it by looking?
feel that blocks disrupt order...
we fail iff at some point someone can't 

can we just sim this?
p: finding next less that is < (we can just compress)
*/

int main(){
	int n;
	cin >> n;
	int sz = 1 << n;
	vector<int> v(sz);
	for(int i = 0;i < sz; ++i){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	vector<int> cmp;
	for(int i = 0;i < sz; ++i){
		if(i && v[i-1] == v[i]){
			cmp.back()++;
		}
		else{
			cmp.push_back(1);
		}
	}
	vector<int> cnt(cmp.size());
	++cnt.back();
	--cmp.back();
	bool ans = true;
	for(int it = 0; it < n; ++it){
		vector<int> add(cmp.size(), 0);
		for(int i = cmp.size()-1;i > 0; --i){
			while(cnt[i] & cmp[i-1] 	== 0){
				cnt[i-1] += cnt[i];
				cnt[i] = 0;
			}
		}
		for(int i = cmp.size()-1;i > 0; --i){
			if(cmp[i-1] > cnt[i]){
				cmp[i-1] -= cnt[i];	
				add[i-1] += cnt[i];
			}
			else{
				int left = cnt[i] - cmp[i-1];
				add[i-1] += cmp[i-1];
				cmp[i-1] = 0;	
				cnt[i] -= left;
				cnt[i-1] += left;
			}
		}
		for(int i = 0;i < add.size(); ++i){
			cnt[i] += add[i];
		}
	}
	int sum = accumulate(cmp.begin(), cmp.end(), 0);
	cout << (sum == 0?"Yes":"No") << '\n';
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    string s;
    cin >> s;
    ll cnt=1;
    for(i=1;i<n;i++){
        if(s[i]!=s[i-1])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n; cin >> n;
        vi a(n),b(n);
        for(int i =0; i<n; i++){
            cin >> a[i];
            b[i] = a[i];
        }
        sort(all(b));
        for(int i = 0; i<n;i++){
            int mx = b[n-1];
            if(mx==a[i]){
                cout<<b[n-2]<<endl;
            }
            else cout<<mx<<endl;
        }



return 0;
}




Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] - '0') ans++;
  }

  cout << ans << endl;

  return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

const string P = "Positive";
const string N = "Negative";
const string Z = "Zero";

int main() {
  ll a,b;
  cin >> a >> b;
  if( a <= 0 && 0 <= b ) puts(Z.c_str());
  else if( 0 < a ) puts(P.c_str());
  else {
    if( b > 0 ) b = 0;
    if( (llabs(llabs(a)-llabs(b))+1LL) % 2LL == 0LL ) puts(P.c_str());
    else puts(N.c_str());
  }

  compute();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    if(a % 2 == 0 || b % 2 == 0)
    {
        std::cout << "Even" << std::endl;
    }
    else
    {
        std::cout << "Odd" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  ll k,a,b;
  cin>>k>>a>>b;
  if((a-1)/k!=b/k)cout<<"OK"<<"\n";
  else cout<<"NG"<<"\n";
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int n, m;
    cin >> n >> m;
    vector<int> vote(n);
    int all = 0;
    rep(i, n){
        cin >> vote.at(i);
        all += vote.at(i);
    }

    int can_select=0;
    rep(i, n){
        if(vote.at(i) >= 1.0/(4.0*m) * all){
            can_select++;
        }
    }
    if(can_select >= m) cout << "Yes\n";
    else cout << "No\n";


    return 0;
}

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

int main() {
  int N, M;
  char Flag[50][50];
  int res = 0;

  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      cin >> Flag[i][j];
    }
  }

  int W[50] = {0};
  int B[50] = {0};
  int R[50] = {0};

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      if(Flag[i][j] == 'W') W[i]+=1;
      else if(Flag[i][j] == 'B') B[i]+=1;
      else R[i]+=1;
    }
    //cout << W[i] << " " << B[i] << " " << R[i] << endl;                             
  }

  int diff = 10000;
  int temp_i = 0;
  int temp, temp_j, temp_k;
  int k;
  for(int i = 0; i < N-2; i++) {
    temp_i += B[i] + R[i];
    temp_j = 0;
    for(int j = i+1; j < N-1; j++) {
      temp_j += W[j] + R[j];
      temp_k = 0;
      for(k = j+1; k < N; k++) {
        temp_k += B[k] + W[k];
	if(k == N-1) {
          temp = temp_i + temp_j + temp_k;
          if(diff > temp) diff = temp;
        }
      }
      //cout << temp << endl;                                                         
    }
  }

  cout << diff << endl;

  return 0;
}




Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();

		System.out.println((a + b) * h / 2);
		sc.close();
	}
}


Measured memory_bytes: 21716
import copy

ABC = list(map(int, input().split()))

ABC.sort()
ABC0=copy.deepcopy(ABC)


def check(x_list):
    sum=0
    for i in x_list:
        sum+=(i%2)
    if sum>0:
        return False
    else:
        return True

def ido(x_list):
    new_list=[x/2 for x in x_list]
    r_list=[]
    for i in range(3):
        r_list.append(new_list[i%3]+new_list[(i+1)%3])
    r_list.sort()
    return r_list

    
count =0    

while check(ABC0):
    ABC0=ido(ABC0)
    count+=1
    if ABC==ABC0:
        count=-1
        break
print(count)

Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct BinarySearchTree {
	struct Node {
		T key;
		Node *l, *r, *p;
		Node() {}
		Node(T key) :key(key) {}
		Node(T key, Node *l, Node *r) :key(key), l(l), r(r) {}
		bool operator<(Node &other) {
			return key < other.key;
		}
		bool operator>(Node &other) {
			return key > other.key;
		}
	};
	Node *root = nullptr, *NIL = nullptr;
	void insert(T key) {
		Node *x = root, *y = NIL;
		while (x != NIL) {
			y = x;
			if (key < x->key)x = x->l;
			else x = x->r;
		}
		dump(y);
		Node *z = (Node*)malloc(sizeof(Node));
		z->l = z->r = NIL;
		z->key = key;
		z->p = y;
		if (y == NIL)root = z;
		else {
			if (key < y->key)y->l = z;
			else y->r = z;
		}
	}
	//void find(T key) {
	Node *find(T key) {
		Node *x = root;
		while (x != NIL&&x->key != key) {
			if (key < x->key)x = x->l;
			else x = x->r;
		}
		//	if (x != NIL)cout << "yes" << endl;
		//	else cout << "no" << endl;
		return x;
	}
	Node *treeMinimum(Node *x) {
		while (x->l != NIL)x = x->l;
		return x;
	}
	Node *treeSuccessor(Node *x) {
		if (x->r != NIL)return treeMinimum(x->r);
		Node *y = x->p;
		while (y != NIL&&x == y->r) {
			x = y;
			y = y->p;
		}
		return y;
	}
	void treeDelete(Node *z) {
		Node *y, *x;
		if (z->l == NIL || z->r == NIL)y = z;
		else y = treeSuccessor(z);

		if (y->l != NIL)x = y->l;
		else x = y->r;

		if (x != NIL)x->p = y->p;

		if (y->p == NIL)root = x;
		else {
			if (y == y->p->l)y->p->l = x;
			else y->p->r = x;
		}

		if (y != z)z->key = y->key;

		free(y);
	}
	void inorder() {
		inorder(root);
		puts("");
	}
	void inorder(Node *u) {
		if (u == NIL)return;
		inorder(u->l);
		printf(" %d", u->key);
		inorder(u->r);
	}
	void preorder() {
		preorder(root);
		puts("");
	}
	void preorder(Node *u) {
		if (u == NIL)return;
		printf(" %d", u->key);
		preorder(u->l);
		preorder(u->r);
	}
};
signed main() {
	int n; scanf("%d", &n);
	BinarySearchTree<int>bst;
	rep(i, 0, n) {
		string com;
		cin >> com;
		if (com == "insert") {
			int x; scanf("%d", &x);
			bst.insert(x);
		}
		else if (com == "print") {
			bst.inorder();
			bst.preorder();
		}
		else if (com == "find") {
			int x; scanf("%d", &x);
			cout << (bst.find(x) == nullptr ? "no" : "yes") << '\n';
		}
		else if (com == "delete") {
			int x; scanf("%d", &x);
			bst.treeDelete(bst.find(x));
		}
	}
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int max_n = a;
  max_n = max(max_n, b);
  max_n = max(max_n, c);
  int min_n = a;
  min_n = min(min_n, b);
  min_n = min(min_n, c);
  int mid = a+b+c - max_n - min_n;
  
  int ans = max_n - mid;
  int div = max_n - min_n - ans;
  if (div % 2 == 0) {
    ans += div / 2;
  } else {
    ans += 1 + div / 2 + 1;
  }
  
  cout << ans << endl;

}

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

using namespace std;

struct thread{
  int th;
  string message;
  vector<thread> child;
  thread(){}
  thread(int th, string message):th(th), message(message){}
};

bool parse(thread &p, int k, string M, int ith)
{
  if(k == p.th){
    p.child.push_back(thread(ith, M));
    return true;
  }
  for(int i = 0; i < p.child.size(); i++){
    if(parse(p.child[i], k, M, ith)) return true;
  }
  return false;
}

void print(thread &c, int r)
{
  for(int i = 0; i < r; i++) cout << ".";
  cout << c.message << endl;
  for(int i = 0; i < c.child.size(); i++){
    print(c.child[i], r + 1);
  }
  return;
}

int main()
{
  int n;
  cin >> n;
  thread channel(0, "");
  for(int i = 0; i < n; i++){
    int k;
    string M;
    cin >> k >> M;
    parse(channel, k, M, i + 1);
  }
  for(int i = 0; i < channel.child.size(); i++){
    print(channel.child[i], 0);
  }
  return 0;
}

Measured memory_bytes: 1824
#include <bits/stdc++.h>
using namespace std;
int main(){
    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<long long>> a(R, vector<long long> (C, 0));
    vector<vector<vector<long long>>> dp(R, vector<vector<long long>> (C, vector<long long> (4, 0)));
    for(int i = 0; i < K; i++){
        long long r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        a[r][c] = v;
        dp[r][c][1] = v;
    }
    dp[0][0][3] = dp[0][0][2] = dp[0][0][1] = a[0][0];
    for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
            for(int k = 0; k < 3; k++){
                if(j != C - 1) dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], max(dp[i][j][k] + a[i][j + 1], dp[i][j][k + 1]));
                if(i != R - 1) {
                    dp[i + 1][j][k + 1] = max(dp[i + 1][j][3], dp[i][j][3] + a[i + 1][j]);
                }
            }
        }
    }
    cout << dp[R - 1][C - 1][3] << endl;
}

Measured memory_bytes: 706752
fun divMod(a: Int, b: Int): Pair<Int, Int> {
    val div = a / b
    val mod = a % b
    return Pair(div, mod)
}

fun main(args: Array<String>) {
    val S = readLine()!!.toInt()
    val (M, s) = divMod(S, 60)
    val (h, m) = divMod(M, 60)

    println("$h:$m:$s")
}



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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;


int main() {
	
	IO;
	
	int n;
	cin >> n;
	
	vector<int> ate(n), sat(n), bonus(n-1);
	
	for (int i = 0; i < n; ++i) cin >> ate[i];
	for (int i = 0; i < n; ++i) cin >> sat[i];
	for (int i = 0; i < n-1; ++i) cin >> bonus[i];
	
	int ans = 0;
	
	for (int i = 0; i < n; ++i) {
		ans += sat[ate[i]-1];
		if (i-1 >= 0 && ate[i-1] +1 == ate[i]) ans += bonus[ate[i-1]-1];
	}
	
	cout << ans;
	
}



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



int main(){
    int n;
    cin>>n;
    int a[n];
    int count=0;
    for(int i=0;i<n;i++)
    cin>>a[i];
    int min=a[0];
    for(int i=0;i<n;i++){
        if(min>=a[i]){
            count++;
            min=a[i];
        }
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
L = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        # if S[i][j] == '#':
        #     L[i][j] = 0
        if S[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
R = [[0] * w for _ in range(h)]
for i in range(h):
    for j in reversed(range(w)):
        # if S[i][j] == '#':
        #     R[i][j] = 0
        if S[i][j] == '.':
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
U = [[0] * w for _ in range(h)]
for j in range(w):
    for i in range(h):
        # if S[i][j] == '#':
        #     U[i][j] = 0
        if S[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1
D = [[0] * w for _ in range(h)]
for j in range(w):
    for i in reversed(range(h)):
        # if S[i][j] == '#':
        #     D[i][j] = 0
        if S[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print(ans)


Measured memory_bytes: 309384
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: String = sc.read();
    let c0 = s.match_indices("0").count();
    let c1 = s.match_indices("1").count();

    println!("{}", std::cmp::min(c0, c1) * 2);
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define Rint register int
#define fi first
#define se second
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, LL> pii;
const int N = 103;
int n, head[N], to[N << 1], nxt[N << 1], deg[N], mxdeg[N], dep[N], q[N], f, r;
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	bool f = false;
	while(ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if(ch == '-') f = true, ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	if(f) x = -x;
}
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
template<typename T>
inline bool chkmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
template<typename T>
inline bool chkmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
inline int bfs(int u, int v){
	int res = 0;
	memset(dep, 0, sizeof dep); f = r = 0;
	q[r ++] = u; dep[u] = 1;
	if(v){q[r ++] = v; dep[v] = 1;}
	while(f < r){
		int x = q[f ++];
		chkmax(mxdeg[dep[x]], deg[x]);
		chkmax(res, dep[x]);
		for(Rint i = head[x];i;i = nxt[i])
			if(!dep[to[i]]){
				dep[to[i]] = dep[x] + 1;
				q[r ++] = to[i];
			}
	}
	return res;
}
inline pii work(int u, int v){
	pii res;
	memset(mxdeg, 0, sizeof mxdeg);
	res.fi = bfs(u, v); res.se = mxdeg[1] - (v != 0);
	for(Rint i = 2;i <= n;++ i){
		if(mxdeg[i] <= 1) break;
		res.se *= (mxdeg[i] - 1);
	}
	if(v) res.se <<= 1;
	return res;
}
pii ans;
int main(){
	read(n);
	if(n == 2) return puts("1 2"), 0;
	for(Rint i = 1, u, v;i < n;++ i){
		read(u); read(v);
		++ deg[u]; ++ deg[v];
		add(u, v); add(v, u);
	}
	ans.fi = n;
	for(Rint i = 1;i <= n;++ i){
		chkmin(ans, work(i, 0));
		for(Rint j = head[i];j;j = nxt[j]) chkmin(ans, work(i, to[j]));
	}
	printf("%d %d\n", ans.fi, ans.se);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int s,w;

    scanf("%d %d",&s,&w);


    if(s>=1 && s<=100 && w>=1 && w<=100)
    {
        if(s<=w)
            printf("unsafe");
        else{
            printf("safe");
        }
    }


    else
    {
        printf("this number not allow");
    }




    return 0;

}


Measured memory_bytes: 1680
S = input()
count = 0
max = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'G' or S[i] == 'T' or S[i] == 'C':
        count += 1
        if max < count:
            max = count
    else:
        count = 0
print(max)

Measured memory_bytes: 38384
nums = []
sum_nums = []
counts = []
while True:
    n, x = input().split(" ")
    n, x = int(n), int(x)
    if n == 0 and x == 0:
        break
    else:
        nums.append(n + 1)
        sum_nums.append(x)

for num, sum_num in zip(nums, sum_nums):
    count = 0
    for i in range(1, num):
        for j in range(i + 1, num):
            for k in range(j + 1, num):
                if (i + j + k) == sum_num:
                    count += 1
    counts.append(count)
for i, num in enumerate(counts):
    print(str(num))



Measured memory_bytes: 5600