akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
public class Main {
		public static void main(String[] arg) throws IOException {
			InputStreamReader is = new InputStreamReader(System.in); 
	        BufferedReader br = new BufferedReader(is);
			String str = br.readLine();
			int num = Integer.parseInt(str);
			System.out.println(num/60/60+":"+num/60%60+":"+num%60);
	}

}

Measured memory_bytes: 24444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN = 200100;
const ll INF = 1e15;
const ll MOD = 1e9+7;
ll N,M,W,a,b,c,d,e;
ll A[MAXN];
vi V;
ll ans=INF;
ll len=0;
deque<ll> dq;
ll B[MAXN];

int main(){
    cin>>N>>M;
    for(int i=1;i<=N;++i)cin>>A[i];
    a=A[1];b=A[A[1]];
    while(a!=b){
        a=A[a];
        b=A[A[b]];
    }
    a=A[a];len=1;
    dq.pb(a);
    B[a]=1;
    while(a!=b){
        ++len;a=A[a];
        dq.pb(a);
        B[a]=1;
    }
    a=1;
    while(M){
        if(B[a])break;
        --M;
        a=A[a];
    }
    if(M==0){cout<<a;return 0;}
    while(dq[0]!=a){
        dq.push_front(dq.back());
        dq.pop_back();
    }
    ll lover=M%len;
    cout<<dq[lover];
    // for(int i=1;i<=N;++i)cout<<L[i]<<' ';
}

Measured memory_bytes: 8180
n = int(input())
a = []
count = 0
for i in range(1,n+1):
     if i%2 != 0:
          for j in range(1,i+1):
               if i%j == 0:
                    a.append(j)
     if len(a) == 8:
          count += 1
     a.clear()
print(count)

Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (x, a, b) = scan!(i64, i64, i64);
    if b - a <= 0 {
        println!("delicious")
    } else if b - a <= x {
        println!("safe")
    } else {
        println!("dangerous")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N, T;
    cin >> N >> T;
    vi A(N);
    rep(i, N) cin >> A[i];

    int mi=A[0], mx = A[0];
    map<int, int> mp;
    int pr=0;

    rep(i, N) {
        if(A[i] < mi) mi = A[i];
        if(A[i]-mi >= pr) {
            pr = A[i]-mi;
            mp[pr]++;
        }
    }

    cout << mp[pr] << endl;

    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, D, ans = 0;
    cin >> N >> D;
    REP(i, N) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= D * D) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
class Main {
  public static void main (String[] args) {
      
      Scanner scan = new Scanner(System.in);
      
      int x = scan.nextInt();
      
      int y =0;
      
      for(int i=1; i<10; i++){
        y = 111*i;
        if(y>=x){
          break;
          }
          }
         System.out.println(y);
         }
        
}

Measured memory_bytes: 23380
#include <iostream>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m) {
		int i, a[10001] = { 0 }, b[10001] = { 0 };
		bool list[2][1001] = { false };
		if (n == 0 && m == 0) goto END;
		for (i = 0; i < m; i++) {
			cin >> a[i] >> b[i];
			if (a[i] == 1) {
				list[0][b[i]] = true;
				list[1][b[i]] = true;
			}
			if (b[i] == 1) {
				list[0][a[i]] = true;
				list[1][a[i]] = true;
			}
		}
		for (i = 0; i < m; i++) {
			if (list[0][a[i]] == true) {
				list[1][b[i]] = true;
			}
			if (list[0][b[i]] == true) {
				list[1][a[i]] = true;
			}
		}
		int ans = 0;
		for (i = 2; i <= n; i++) {
			if (list[1][i]) ans++;
		}
		cout << ans << endl;
	}
END:;
	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++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;}
constexpr long INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> v(n);REP(i,n) cin >> v[i];

    double ans = 0.0;
    REP(i,n)
        ans += 1.0 / v[i];
    ans = 1.0 / ans;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans = [1]*n

for i in range(m):
    a,b = map(int,input().split())
    if h[a-1]<h[b-1]:
        ans[a-1] = 0
    elif h[a-1]>h[b-1]:
        ans[b-1] = 0
    elif h[a-1] == h[b-1]:
        ans[a-1] = ans[b-1] = 0

print(ans.count(1))

Measured memory_bytes: 20140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    vi neg,pos;
    vector<ll>ans;
    int n,k;
    scanf("%d%d",&n,&k);
    int z = 0;
    ll res=1;
    lp(i,n){
        int x;
        scanf("%d",&x);
        if(x>0)pos.pb(x);
        else if(x<0)neg.pb(-x);
        else z++;
        res  = (res*x%MOD+MOD)%MOD;
    }
    sort(all(pos));
    sort(all(neg));
    int idx = 0,it = 0,nev=0,temp=k;
    if(n==k){
        printf("%lld",res);
        return 0;
    }else if(sz(pos)+sz(neg)/2*2<k){
        puts("0");
        return 0;
    }
    res = 1;
    if(k&1){
        if(sz(pos)){
            res *= (ll)pos.back()%MOD;
            pos.pop_back();
            k--;
        }else{
            if(z){
                puts("0");
                return 0;
            }
            lp(i,k){
                res = (res*(-neg[i])%MOD+MOD)%MOD;
            }
            printf("%lld",res);
            return 0;

        }
    }
    for(int i=sz(pos);i>=2;i-=2){
        ans.pb(1ll*pos[i-1]*pos[i-2]);
    } 
    for(int i=sz(neg);i>=2;i-=2){
        ans.pb(1ll*neg[i-1]*neg[i-2]);
    }
    k/=2;
    sort(all(ans));
    reverse(all(ans));
    lp(i,k){
        res=1ll*(ans[i]%MOD)*res%MOD;
    }
    printf("%lld",res);
    return 0;
}

Measured memory_bytes: 5528
#include <stdio.h>

int main(void){
	int x,y;
	while(1){
		scanf("%d %d",&x, &y);
		if(x==0 && y==0) break;
		if(x<=y) printf("%d %d\n",x, y);
		else printf("%d %d\n",y, x);
	}
	return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<pair<int,ll>> v[101010];
vector<ll> a(101010);

void dfs(int x,int p){
    for(auto to : v[x]){
        if(to.first==p)continue;
        a[to.first]=a[x]+to.second;
        dfs(to.first,x);
    }
}
int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int x,y,z;
        cin>>x>>y>>z;
        --x;--y;
        v[x].emplace_back(y,z);
        v[y].emplace_back(x,z);
    }
    dfs(0,-1);
    rep(i,n){
        cout<<a[i]%2<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 10240
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    x=list(map(int,readline().split()))
    x.sort()
    d=[0]*(m-1)
    for i in range(1,m):
        d[i-1]=x[i]-x[i-1]

    d.sort()
    print(sum(d[:max(0,m-n)]))

if __name__=="__main__":
    main()

Measured memory_bytes: 13308
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  print $ solve n
  where
    solve n = solve' 0 1 n
    solve' ans i n | i > n = ans
                   | otherwise =
                     let c = countB i n
                     in
                       solve' (ans + c) (i + 1) n
    countB a n =
      let s = show a
          ah = read [head s] :: Int
          al = read [last s] :: Int
          c1 = if ah == al then 1 else 0
          c2 = if al /= 0 && al*10+ah <= n then 1 else 0
      in
        c1 + c2
        + countB' 100 al ah n
        + countB' 1000 al ah n
        + countB' 10000 al ah n
        + countB' 100000 al ah n

    countB' x al ah n | al == 0 = 0
                      | otherwise =
                        let
                          m = al * x + ah
                          d = n - m
                          c1 = x `div` 10
                          c2 = d `div` 10 + 1
                        in if d < 0
                           then 0
                           else min c1 c2

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int dp[1024][100001],v[323456],w[323456];
int n,q;

int f(int a,int l) {
  if(l<0) return -1e9;
  if(!a) return 0;
  if(a>1023) return max(f(a/2,l),f(a/2,l-w[a])+v[a]);
  if(dp[a][l]>=0) return dp[a][l];
  return dp[a][l]=max({f(a/2,l),f(a,l-1),f(a/2,l-w[a])+v[a]});
}

int main() {
  cin >> n;
  memset(dp,-1,sizeof(dp));
  for(int i=1;i<=n;i++) cin >> v[i] >> w[i];
  cin >> q;

  while(q--) {
    int a,l;
    cin >> a >> l;
    cout << f(a,l) << endl;
  }
}

Measured memory_bytes: 413440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int INF = 100001;
  vector<int> A(INF, 0);
  for (int i=0; i<N; i++) {
    int a;
    cin >> a;
    if (a == 0) {
      A.at(0)++; A.at(1)++; 
    } else {
      A.at(a-1)++; A.at(a)++; A.at(a+1)++;
    }
  }
  
  sort(A.begin(), A.end(), greater<int>() );
  
  cout << A.at(0) << endl;
  
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,ans = 0;
	cin >> n >> k;
	int a[10000];
	for(int i = 0;i <= n-1;i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for(int i = 0;i <= k-1;i++)
	{
		ans = ans+a[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

LL rec(LL x,LL y,int fx,int fy){
    LL r=LLMAX/2;
    if(x<=y)
        r=min(r,y-x);
    if(fx<2)
        r=min(r,1+rec(-x,y,fx+1,fy));
    if(fy<2)
        r=min(r,1+rec(x,-y,fx,fy+1));
    return r;
}

int main(void){
    LL x,y;
    cin>>x>>y;
    cout<<rec(x,y,0,0)<<endl;
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())

typedef	long long ll;

const int MAX = 3000;
const ll MOD = 998244353;

ll ways[MAX];

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, s;
	cin >> n >> s;
	ways[0] = 1;
	ll ans(0);

	for (int i(0); i < n; ++i)
	{
		int val;
		cin >> val;
		for (int x(s); x > val; --x)
		{
			ways[x] += ways[x-val];
			ways[x] %= MOD;
		}
		ways[val] += i+1;
		ways[val] %= MOD;
		ans += ways[s];
		ans %= MOD;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
const int INF = 7+(1e+9);
int main()
{
    int n,k;
    cin>>n>>k;
    int sum=0;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        if(x>=k){
            sum++;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll all = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		all ^= a[i];
	}
	for (int i = 0; i < n; i++) {
		cout << (a[i] ^ all) << " ";
	}
}

Measured memory_bytes: 4780
#include <stdio.h>


int main(){
	
	int a,b[201],i,count;
	scanf("%d",&a);
	
	for(i=0;i<a;i++){
		count=0;
		scanf("%d",&b[i]);
		while(b[i]){
			if(b[i]%2==0){
				count=count+1;
				b[i]=b[i]/2;
			} else {
				break;
			}
		}
		b[i]=count;
	}
	
	count=100;
	
	for(i=0;i<a;i++){
		if(count>b[i])count=b[i];
	}
	
	printf("%d\n",count);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, k;
	cin >> n >> k;
	vll snk(n, 0);
	for (ll i = 0; i < k; i++) {
		ll d;
		cin >> d;
		for (ll j = 0; j < d; j++) {
			ll a;
			cin >> a;
			snk[a - 1]++;
		}
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		if (snk[i] == 0) ans++;
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

string N;

void solve() {
	cin >> N;
	int a[N.size()], inv[N.size()];
	ll ans = 0;
	for (int i = 0; i < (int)N.size(); i++) {
		a[i] = (int)(N[i] - '0');
		inv[i] = -1;
		// ans += dp[i];
	}
	
	// Figure out what segments are better to inverse
	for (int i = N.size() - 1; i >= 0; --i) {
		if (a[i] > 5) {
			inv[i] = i;
			if (i + 1 < (int)N.size() && inv[i + 1] != -1) inv[i] = inv[i + 1];
		} else if (a[i] == 5) {
			if (i + 1 < (int)N.size() && inv[i + 1] != -1) inv[i] = inv[i + 1];
			else if (i > 0 && a[i - 1] >= 5) inv[i] = i;
		} else if (a[i] == 4) {
			if (i > 0 && i < (int)N.size() - 1) {
				if (a[i - 1] >= 5 && inv[i + 1] != -1) {
					inv[i] = inv[i + 1];
				}
			}
			
		}
	}
	
	int end = -1;
	for (int i = 0; i < (int)N.size(); i++) {
		if (end == -1) {
			if (inv[i] == -1) ans += a[i];
			else {
				ans += 2;
				end = inv[i];
				ans += 9 - a[i];
			}
		} else {
			ans += 9 - a[i];
		}
		if (i == end) end = -1;
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ms(x, t) memset(x, t, sizeof(x))
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define mp make_pair
#define pb push_back
#define pf push_front
#define endl "\n"
typedef pair<int, int> pll;
typedef pair<int, pll> plll;
typedef vector<int> vl;
typedef vector<vector<int>> vvl;
typedef vector<pll> vpll;
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a, b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;

const int limit = 1e5 + 1;
const int inf = 1e7;
const int mod = 1e9 + 7;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

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

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

    int N, M, X, tmp_m;
    cin >> N >> M >> X;
    vector<int> m = {};
    for(int i=0; i<M; ++i){
        cin >> tmp_m;
        m.push_back(tmp_m);
    }

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


    int left = 0;
    int right = 0;
    for(int j=0; j<M; ++j){
        if(m[j] < X){
            ++left;
        }else{
            ++right;
        }
    }

    cout << min(left, right) << endl;

    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <queue>

using namespace std;

int main() {

	int N, shortest, largest, sum, tmp;

	while (true) {
		cin >> N;
		if (N == 0)
			break;

		sum = 0;
		shortest = 10000;
		largest = -1000;

		for (int i = 0; i < N; i++) {
			cin >> tmp;
			sum += tmp;
			shortest = min(shortest, tmp);
			largest = max(largest, tmp);
		}

		sum -= shortest;
		sum -= largest;

		cout << sum / (N - 2) << endl;

	}

	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
using std::cin;
using std::cout;
using std::endl;
using std::sort;
using std::greater;

int main() {
	const int N = 5;
	int num[N];
	for (int i = 0; i < N; ++i) {
		cin >> num[i];
	}
	sort(num, num + N, greater<int>());
	for (int i = 0; i < N; ++i) {
		cout << num[i];
		if (i == N - 1) {
			cout << endl;
		} else {
			cout << ' ';
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	n = n%10;
	switch(n){
		case 0: cout << "pon";break;
		case 1: cout << "pon";break;
		case 2: cout << "hon";break;
		case 3: cout << "bon";break;
		case 4: cout << "hon";break;
		case 5: cout << "hon";break;
		case 6: cout << "pon";break;
		case 7: cout << "hon";break;
		case 8: cout << "pon";break;
		case 9: cout << "hon";break;
	}
	return 0;
}





Measured memory_bytes: 3548
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a=int(input())
if a==1:
  print(0)
  exit()
b=factorization(a)
ans=0
for i in range(len(b)):
  t=1
  while t<=b[i][1]:
    ans+=1
    b[i][1]-=t
    t+=1
print(ans)
    


Measured memory_bytes: 63232
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

vector<pair<int64_t, int64_t>> prime_factorize(int64_t n) {
    vector<pair<int64_t, int64_t>> res;
    for (int64_t p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0){
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int64_t Euclidean(int64_t a, int64_t b){
    // b = a * q + r
    if(a > b) swap(a, b);
    int64_t r = b % a;
    if (r == 0) return a;
    else return Euclidean(a, r);
}

int main(){
    int64_t A, B;
    cin >> A >> B;
    int64_t gcd = Euclidean(A, B);
    auto pf = prime_factorize(gcd);
    cout << pf.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    int a,b,c;
    long x,y; 
    cin >> a>> b>> c>> x >>y;
    long long cost=0;
    if(a+b<=2*c){
        cost=a*x+b*y;
    }else if (a+b > 2*c){
        if(x>=y){
            cost += 2*c*y;
            if(a > 2*c){
                cost += 2*c*(x-y);
            }else{
                cost += a*(x-y);
            }
        }else{
            cost += 2*c*x;
            if(b > 2*c){
                cost += 2*c*(y-x);
            }else{
                cost += b*(y-x);
            }
        }
    }
    

    
    cout << cost << endl;
    
    
    return 0;
}

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

int x, a, b;

int main() {
  cin >> x >> a >> b;
  b -= a;
  if(b <= 0)
    cout << "delicious" << endl;
  else if(b <= x)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 256
//package AtCoder;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
class Main {

	public static void solve() {
		int x = s.nextInt();
		out.println(x ^ 1);
	}

	public static void main(String[] args) {
		new Thread(null, null, "Thread", 1 << 27) {
			public void run() {
				try {
					out = new PrintWriter(new BufferedOutputStream(System.out));
					s = new FastReader(System.in);
					solve();
					out.close();
				} catch (Exception e) {
					e.printStackTrace();
					System.exit(1);
				}
			}
		}.start();
	}

	public static PrintWriter out;
	public static FastReader s;

	public static class FastReader {

		private InputStream stream;
		private byte[] buf = new byte[4096];
		private int curChar, snumChars;

		public FastReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (snumChars == -1) {
				throw new InputMismatchException();
			}
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException E) {
					throw new InputMismatchException();
				}
			}
			if (snumChars <= 0) {
				return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int number = 0;
			do {
				number *= 10;
				number += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long number = 0;
			do {
				number *= 10L;
				number += (long) (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextLong();
			}
			return arr;
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndofLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndofLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	
}


Measured memory_bytes: 32580
#include <stdio.h>

int main(){
  int q,a[2]={499999,500000},t,f,g=0;
  char s[1000000],c[2];
  scanf("%s",&s[a[1]]);
  while(s[a[1]]!=0) a[1]++;
  scanf("%d",&q);
  for(;q>0;q--){
    scanf("%d",&t);
    if(t==1){
      g^=1;
    }else{
      scanf("%d",&f);
      f--;
      f^=g;
      scanf("%s",&c);
      s[a[f]]=c[0];
      a[f]+=(f<<1)-1;
    }
  }
  s[a[1]]=0;
  a[0]++; a[1]--;
  if(g){
    f=(a[0]+a[1]);
    for(q=a[0];q<=f/2;q++){
      t=s[q];
      s[q]=s[f-q];
      s[f-q]=t;
    }
  }
  printf("%s",&s[a[0]]);
  return(0);
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int MN = 400100;
int s[MN],t[MN];
int st[MN],tt[MN];
int b[MN];
int n;
void kp() {
	int i=0,j=-1;b[0] = -1;
	while(i < n-1) {
		while((j >= 0) && (st[j] != st[i])) {
			j = b[j];
		}
		j++;i++;
		b[i] = j;
	}
}
vi res;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> s[i];
	}
	for(int i=0;i<n;i++) {
		cin >> t[i];
		t[i+n] = t[i];
	}
	if(n == 1) {
		cout << 0 << " " << (t[0]^s[0]) << '\n';
		return 0;
	}
	for(int i=1;i<n;i++) {
		st[i-1] = s[i]^s[i-1];
	}
	for(int i=1;i<2*n;i++) {
		tt[i-1] = t[i]^t[i-1];
	}
	kp();
	int po = 0;
	for(int i=0;i<2*n-2;i++) {
		while((po >= 0) && (st[po] != tt[i])) {
			po = b[po];
		}
		po++;
		if(po == n-1) {
			res.push_back(i);
			po = b[po];
		}
	}
	for(int i=0;i<res.size();i++) {
		res[i] = ((n-(res[i]-(n-2)))%n);
	}
	sort(res.begin(),res.end());
	for(int i=0;i<res.size();i++) {
		int id = ((n-res[i]))%n;
		cout << res[i] << " " << (s[0]^t[id]) << '\n';
	}
}


Measured memory_bytes: 10612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll N;

class BIT{
public:
  ll n;
  vector<ll> bit;
  BIT(ll n):n(n),bit(n+1,0){}
  
  void add(ll i,ll x){
    if(i==0) return;
    for(ll k=i;k<=n;k+=(k & -k)) bit[k]+=x;
  }
  
  ll sum(ll i){
    ll s=0;
    if(i==0) return s;
    for(ll k=i;k>0;k-=(k & -k)) s+=bit[k];
    return s;
  }
};

// 数列Sの転倒数(i<j かつ S[i]>S[j] を満たすものの数)
ll inversion(vector<ll> S){
  ll mn=0;
  RREP(i,N) chmin(mn,S[i]);
  REP(i,N+1) S[i]-=mn,S[i]++;
  
  ll num=0;
  BIT U(N+1);
  REP(i,N+1){
    num+=i-U.sum(S[i]);
    U.add(S[i],1);
  }
  return num;
}

// 中央値がmid以上になる部分列の数
ll cnt(vector<ll> A,ll mid){
  vector<ll> B(N),S(N+1);
  REP(i,N){
    if(A[i]>=mid) B[i]=1;
    else B[i]=-1;
  }
  
  S[0]=0;
  RREP(i,N) S[i]=S[i-1]+B[i-1];
  
  return N*(N+1)/2-inversion(S);
}

int main(){
  cin>>N;
  vector<ll> A(N);
  REP(i,N) cin>>A[i];
  
  ll ok=0ll,ng=MOD;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(2*cnt(A,mid)>=N*(N+1)/2) ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<char,int> mp;
  rep(i,n) {
    mp[s[i]]++;
  }
  ll ans=1;
  for(auto p: mp) {
    ans*=(p.second+1);
    ans%=INF;
  }
  if(ans==0) ans=INF-1;
  else ans--;
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

const ll MAX_N=1e5;
const ll MAX_M=1e9;

ll N,M;
ll a[MAX_N+5];

bool ok=true;

ll gcd(ll a,ll b){
    if(a%b!=0)return gcd(b,a%b);
    else return b;
}

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

ll count(ll x){
    ll res=0;
    while(x%2==0){
        x/=2;
        res++;
    }
    return res;
}

int main(){
    cin>>N>>M;
    for(int i=0;i<N;++i){
        cin>>a[i];
        ll x=a[i]/2;
        if(i!=0&&count(a[i])!=count(a[i-1]))ok=false;
    }
    if(!ok){
        cout<<0<<endl;
        return 0;
    }
    ll X=a[0]/2;
    for(int i=1;i<N;++i){
        X=lcm(X,a[i]/2);
        if(X>M){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=0;
    for(ll i=1;i<=M;++i){
        if(X*(2*i-1)>M)break;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import numpy as np
N = int(input())

def dfs(s):
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0'))


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

int main(){
  int n,m,cnt1=0,cnt2=0;
  string tmp;
  cin >> n;
  vector<string> linen(n);
  for(int i=0;i<n;i++){
    cin >> tmp;
    linen.at(i)=tmp;
  }
  cin >> m;
  vector<string> linem(m);
  for(int i=0;i<m;i++){
    cin >> tmp;
    linem.at(i)=tmp;
  }
  for(int i=0;i<n;i++){
    tmp=linen.at(i);
    for(int j=0;j<n;j++){
	  if(tmp==linen.at(j))cnt2++;
    }
    for(int j=0;j<m;j++){
      if(tmp==linem.at(j))cnt2--;
    }
    if(cnt2>=cnt1)cnt1=cnt2;
    cnt2=0;
  }
  if(cnt1<0)cnt1=0;
  cout << cnt1 << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string N;
    cin >> N;
    ll ans = 0;
    iter(c, N) ans += c - '0';
    if(stoll(N) % ans == 0) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

template<typename T>
T in(){
	T val;
	cin >> val;
	return val;
}

template<typename T>
vector<T> inv(ll num) {
	vector<T> val(num);
	rep(i,num) cin >> val[i];
	return val;
}

//----------------------------------------------------------------------
void solve() {
	ll n,m;
	cin >> n >> m;
	vector<ll> wa(n,0);
	vector<bool> ac(n,false);

	rep(i,m) {
		ll p;
		string s;
		cin >> p >> s;
		p--;
		if (s=="AC") ac[p]=true;
		else if (ac[p]==false) wa[p]++;
	}

	ll sum=0;
	ll pena=0;
	rep(i,n) {
		if (ac[i]) {sum++;pena += wa[i];}
	}

	cout << sum << " " << pena;

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


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

int main()
{
  int n, mid, ans = 0;
  cin >> n;
  mid = n / 2;
  vector<int> d(n);
  for (int i = 0; i < n; i++)
    cin >> d[i];
  sort(d.begin(), d.end());
  ans = d[mid] - d[mid - 1];
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, s;
  cin >> n >> s;
  vector<vector<mint>> dp(n+1, vector<mint>(s+1, 0));
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  dp.at(0).at(0) = 1;
  rep(i, n){
    rep(j, s+1){
      dp.at(i+1).at(j) = dp.at(i).at(j)*2;
      if(j - a.at(i) >= 0) dp.at(i+1).at(j) += dp.at(i).at(j-a.at(i));
      // cerr << dp.at(i+1).at(j).x << " ";
    }
    // cerr << endl;
  }
  cout << dp.at(n).at(s).x << endl;
  return 0;
}

Measured memory_bytes: 73632
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        m: usize,
        mat: [(usize1, usize1); m]
    }

    let mut dp = [-1; 100001];
    let mut v = vec![vec![]; n];

    for (x, y) in mat {
        v[x].push(y);
    }

    let mut res = 0;
    for i in 0..n {
        res = cmp::max(res, dfs(i, &mut dp, &v));
    }

    println!("{}", res);
}

fn dfs(v: usize, dp: &mut[i32], mat: &Vec<Vec<usize>>) -> i32 {
    if dp[v] != -1 {
        return dp[v];
    }

    let mut res = 0;

    for m in &mat[v] {
        res = cmp::max(res, dfs(*m, dp, mat) + 1);
    }

    dp[v] = res;
    res    
}


Measured memory_bytes: 15612
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int n, num = 0;

	cin >> n;

	bool exi = false;

	for (int d = 0; d * 7 <= n; d++)
	{
		for (int c = 0; c * 4 <= n; c++)
		{
			
			if (n == c * 4 + d * 7) {
				exi = true;
			}
			
		}
	}

	if (exi)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

string S[2010];
int r[2010][2010];
int l[2010][2010];
int u[2010][2010];
int d[2010][2010];

int main()
{

	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];

	for (int i = 0; i < H; i++) {
		if (S[i][0] == '.') l[i][0] = 1;
		else l[i][0] = 0;
		for (int j = 1; j < W; j++) {
			if (S[i][j] == '.') l[i][j] = l[i][j - 1] + 1;
			else l[i][j] = 0;
		}
	}

	for (int i = 0; i < H; i++) {
		if (S[i][W - 1] == '.') r[i][W - 1] = 1;
		else r[i][W - 1] = 0;
		for (int j = W - 2; j >= 0; j--) {
			if (S[i][j] == '.') r[i][j] = r[i][j + 1] + 1;
			else r[i][j] = 0;
		}
	}

	for (int i = 0; i < W; i++) {
		if (S[0][i] == '.') u[0][i] = 1;
		else u[0][i] = 0;
		for (int j = 1; j < H; j++) {
			if (S[j][i] == '.') u[j][i] = u[j - 1][i] + 1;
			else u[j][i] = 0;
		}
	}

	for (int i = 0; i < W; i++) {
		if (S[H - 1][i] == '.') d[H - 1][i] = 1;
		else d[H - 1][i] = 0;
		for (int j = H - 2; j >= 0; j--) {
			if (S[j][i] == '.') d[j][i] = d[j + 1][i] + 1;
			else d[j][i] = 0;
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3);
			//cout << r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3 << " ";
		}
		//cout << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 67456
using System;
using static System.Console;

namespace AOJ
{
    public class ALDS1_1_C
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            var A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(ReadLine());
            }

            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                if (IsPrimeB(A[i]))
                {
                    cnt++;
                }
            }
            
            WriteLine(cnt);
        }

//        public static bool IsPrimeA(int x)
//        {
//            if (x <= 1) return false;
//
//            int y = x - 1;
//            while(y > 1)
//            {
//                if (x % y == 0) return false;
//                y--;
//            }
//
//            return true;
//        }

        public static bool IsPrimeB(int x)
        {
            if (x <= 1) return false;
            
            // Composite Number ==  not Prime Number
            double r = Math.Sqrt(x);
            for (int i = 2; i <= r; i++)
            {
                if (x % i == 0) return false;
            }

            return true;
        }
    }
}



Measured memory_bytes: 15900
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main() {
    
    ll A,B,K;
    cin >> A >> B >> K;
    ll tkhs = 0;
    ll aoki = 0;
    if(A-K >= 0){
        tkhs = A-K;
        aoki = B;
    }else{
        tkhs = 0;
        if(A+B-K >= 0) aoki = A+B-K;
        else aoki = 0;
    }
    cout << tkhs << " " << aoki << endl;
    return 0;
}


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

int H, A[MAX + 1];

void maxheapify(int i){
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    if (l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if (r <= H && A[r] > A[largest]) largest = r;

    if (largest != i){
        swap(A[i], A[largest]);
        maxheapify(largest);
    }
}

int main(){
    cin >> H;

    for (int i = 1; i <= H; i++) cin >> A[i];

    for (int i = H / 2; i >= 1; i--) maxheapify(i);

    for (int i = 1; i <= H; i++){
        cout << " " << A[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4976