akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> tallers(n);
	for(int i = 0; i < n; i++){
		cin >> tallers.at(i);
	}
	int count = 0;
	for(int j = 0; j < n; j++) {
		if(tallers.at(j) >= k){
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int mod = 1000000007;
const int max_n = 2000050;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);
mint dp[1000100][2];

int main(){
    ll n;cin >> n;
    vl h(n);rep(i,n)cin >> h[i];
    rep(i,n-1){
        if(h[i]!=h[i+1])h[i+1]--;
    }
    bool che=true;
    rep(i,n-1){
        if(h[i]>h[i+1])che=false;
    }
    if(che)cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 51056
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		int x[][] = new int[h][w];

		for (int i = 0; i < h; i++) {
			String e = in.next();
			for (int j = 0; j < w; j++) {
				if (e.charAt(j) == '#') {
					x[i][j] = 1;
				} else {
                    x[i][j] = 0;
				}
			}
		}
		int sum=0;

		for(int i=0;i<h;i++) {//横
			for(int j=0;j<w;j++) {
				 sum +=x[i][j];
			}
			if(sum==0) {
				for(int j=0;j<w;j++) {
					 x[i][j]=2;
				}
			}
			sum=0;
		}


		for(int j=0;j<w;j++) {//縦
			for(int i=0;i<h;i++) {
				if(x[i][j]!=2) {
				sum +=x[i][j];
				}
			}
			if(sum==0) {
				for(int k=0;k<h;k++) {
					 x[k][j]=2;
				}
			}
			sum=0;
		}


		for(int i=0;i<h;i++) {//横
			for(int j=0;j<w;j++) {
				if(x[i][j]==1) {
					System.out.print('#');
				}
				if(x[i][j]==0) {
					System.out.print('.');
				}
				sum+=x[i][j];
			}
			if(sum!=w*2) {
				System.out.print('\n');
			}
			sum=0;
		}
	}
}

Measured memory_bytes: 24528
#include <stdio.h>
#include <cstdio>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>


const int H_Max = 100;
const int W_Max = 100;


int map[W_Max][H_Max] = { 0 };



int main()
{
	int H, W;
	char buf;
	scanf("%d%d", &H, &W);


	// 改行
	scanf("%c", &buf);

	for (int a = 1; a <= H; ++a)
	{
		for (int b = 1; b <= W; ++b)
		{

			scanf("%c", &buf);

			if (buf == '#')
			{
				map[a][b] = -1;
				if (map[a - 1][b    ] != -1)map[a - 1][b]++;
				if (map[a - 1][b - 1] != -1)map[a - 1][b - 1]++;
				if (map[a - 1][b + 1] != -1)map[a - 1][b + 1]++;
				if (map[a + 1][b    ] != -1)map[a + 1][b    ]++;
				if (map[a + 1][b - 1] != -1)map[a + 1][b - 1]++;
				if (map[a + 1][b + 1] != -1)map[a + 1][b + 1]++;
				if (map[a	 ][b + 1] != -1)map[a	 ][b + 1]++;
				if (map[a	 ][b - 1] != -1)map[a	 ][b - 1]++;
			};

		}

		// 改行
		scanf("%c", &buf);

	}

	for (int a = 1; a <= H; ++a)
	{
		for (int b = 1; b <= W; ++b)
		{
			if (map[a][b] == -1) printf("#");
			else printf("%d", map[a][b]);
		}
		puts("");
	}



	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String[] list = S.split("", 0);

		for (String num : list) {
			if(num.equals("7")) {
				seven++;
			}
		}
		if(seven == 0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 35640
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    vector<i64> A(N), B(N);
    vector<pair<i64, int>> X(N), P(N);
    for (auto& x : X) cin >> x.second;
    for (auto& x : X) cin >> x.first;
    sort(WHOLE(X));
    for(int i = 0; i < N; i++) {
        tie(B[i], A[i]) = X[i];
        P[i] = {A[i], i};
    }
    sort(WHOLE(P));
    bool ans = true;
    for(int i = 0; i < N; i++) {
        ans &= P[i].first <= B[i];
    }
    vector<int> M(N, 0);
    int p = 0;
    while(!M[p]) {
        M[p] = 1;
        p = P[p].second;
    }

    if(accumulate(WHOLE(M), 0) >= N) {
        ans = false;
        for(int i = 0; i < N - 1; i++) {
            ans |= P[i + 1].first <= B[i];
        }
    }
    R_YesNo(ans);
    return 0;
}

Measured memory_bytes: 5376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int len = s.length;

			int ans  = 0;

			Set<Integer> set = new HashSet<>();
			int t = 0;
			if (len % 2 == 0) {
				for (int l = len/2-1, r = len/2; r < len; l--, r++) {
					if (s[l] == s[r]) {
						set.add(s[l]-'0');
						if (set.size() <= 1) {
							t++;
						} else {
							break;
						}
					} else {
						break;
					}
				}
			} else {
				for (int l = len/2, r = len/2; r < len; l--, r++) {
					if (s[l] == s[r]) {
						set.add(s[l]-'0');
						if (set.size() <= 1) {
							t++;
						} else {
							break;
						}
					} else {
						break;
					}
				}
			}

			out.println(len/2+t);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 24276
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

int linearSearch(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}
int main()
{
    int n;
    int A[10000+1];
    int q;
    int key;
    int sum = 0;

    scanf("%d", &n);
    for (int i=0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (int i=0; i<q; i++) {
        scanf("%d", &key);
        if (linearSearch(A, n, key)) sum++;
    }
    printf("%d\n", sum);

    return 0;
}

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

int main()
{
  int N;
  double v[8];
  
  while(cin >> N, N) {
    for(int i = 0; i < N + 3; i++) cin >> v[i];

    int ret = N + 2;
    for(int i = 0; i <= N + 1; i++) {
      double c = 0;
      for(int j = 0; j <= N + 1; j++) {
        if(i == j) continue;
        double tmp = v[j];
        for(int k = 0; k <= N + 1; k++) {
          if(i == k || j == k) continue;
          tmp *= (N + 2 - k) * 1.0 / (j - k);
        }
        c += tmp;
      }
      if(fabs(c - v[N + 2]) < 1e-3) {
        ret = i;
        break;
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1232
N = int(input())
A = list(map(int,input().split()))
ans = 0
y = []
x = 0
z = 1
while x == 0:
    for i in range(N):
        a = str(A[i] % (2 ** z))
        y.append(a)
    if y.count('0') == N:
        ans += 1
        y = []
        z += 1
    else:
        x =+ 3
print(ans)

Measured memory_bytes: 9084
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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



















int main(){
    ll n, d;
    cin >> n >> d;
    vector<vector<ll>> x(n, vector<ll>(d));
    REP(i, n){
        REP(j, d){
            cin >> x[i][j];
        }
    }
    ll ans = 0;
    REP(i, n - 1){
        for(ll j = i + 1; j < n; j++){
            double s = 0;
            REP(k, d){
                s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if((ll)(sqrt(s)) * (ll)(sqrt(s)) == s){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
ans = 0
 
def dfs(i, cur, sum_v):
    global ans, S
    if i == len(S)-1:
        ans += sum_v
        return 
    dfs(i+1, int(S[i+1]), sum_v+int(S[i+1]))
    dfs(i+1, cur*10+int(S[i+1]), sum_v+cur*9+int(S[i+1]))
 
S = input()
dfs(0, int(S[0]), int(S[0]))
print(ans)

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

#[allow(dead_code)]
const M: i64 = 1_000_000_007;
struct PowerPermutation { n: usize, m: usize, ar: Vec<usize> }
impl PowerPermutation {
    fn new(n: usize, m: usize) -> PowerPermutation {
        let ar = vec![0; m];
        PowerPermutation { n: n, m: m, ar: ar }
    }
}
impl Iterator for PowerPermutation {
    type Item = Vec<usize>;
    fn next(&mut self) -> Option<Vec<usize>> {
        if self.ar[self.m-1] >= self.n { return None }
        let r = self.ar.clone();
        self.ar[0] += 1;
        for i in 0..self.m-1 {
            if self.ar[i] == self.n {
                self.ar[i] = 0;
                self.ar[i + 1] += 1;
            } else {
                break;
            }
        }
        return Some(r);
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let mut sws: Vec<Vec<usize>> = vec![vec![]; m];
    for i in 0..m {
        let k: usize = sc.cin();
        for _ in 0..k {
            let s: usize = sc.cin();
            sws[i].push(s - 1);
        }
    }
    let ps: Vec<usize> = (0..m).map(|_| sc.cin()).collect();
    let mut ans = 0;
    for ons in PowerPermutation::new(2, n) {
        let mut ok = true;
        for i in 0..m {
            let a: usize = sws[i].iter().map(|&k| ons[k]).sum();
            if a % 2 != ps[i] {
                ok = false;
                break;
            }
        }
        if ok { ans += 1; }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<cctype>
#include<string>
#include<bitset>
#include<vector>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<set>
#include<map>
#define INF 1000000000
#define ll long long
#define mod 10007
#define pb push_back
using namespace std;
char *fs,*ft,buf[1<<15];
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=200010;
int a[MAXN],sum[MAXN];
int ans,cnt;
int n,k;
int main()
{
	//freopen("1.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+1+n);
	for(int i=2;i<=n;++i)if(a[i]==a[i-1]){puts("NO");return 0;}
	puts("YES");
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.PB({N, 1});
    return res;
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll A, B;
    cin >> A >> B;
    ll max=gcd(A,B);
    
    ll count=0;
    const auto res=prime_factorize(max);
    rep(i,res.size()){
        if(is_prime(res[i].F)){
            count++;
        }
    }   
    cout << count+1 << endl;
}

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

const int vx[] = {-1, 1, 0, 0};
const int vy[] = {0, 0, -1, 1};

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> g(h + 2, vector<char>(w + 2, '.'));

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> g[i][j];
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (g[i][j] == '.') continue;

      bool ok = false;
      for (int k = 0; k < 4; k++) {
        if (g[i + vy[k]][j + vx[k]] == '#') ok = true;
      }
      if (!ok) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, M;
	cin >> N >> M;
	scc_graph g(N);
	rep(i, M) {
		int u, v;
		cin >> u >> v;
		g.add_edge(u, v);
	}
	vector<vi> ans = g.scc();
	int nn = ans.size();
	cout << nn << endl;
	rep(i, nn) {
		int n = ans[i].size();
		cout << n;
		rep(j, n)
			cout << " " << ans[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 40104
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	boolean result = true;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int K = Integer.parseInt(tokens[0]);
		int X = Integer.parseInt(tokens[1]);
		if (K * 500 >= X) {
			result = true;
		} else {
			result = false;
		}
	}

	void calc() {
	}

	void showResult() {
		System.out.println((result ? "Yes" : "No"));
	}
}


Measured memory_bytes: 22612
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter
import itertools

n = int(readline())
s = [input()[0] for i in range(n)]
counter = Counter(s)
ans = 0
for i, j, k in itertools.combinations('MARCH', 3):
    ans += counter[i] * counter[j] * counter[k]
print(ans)


Measured memory_bytes: 4220
#include <cstdio>
#define abs(x) ((x >0)? x :( -( x )))
int H, W, D, A;
int Q, L, R;
int px[90001], py[90001];
int d[90001];
int main()
{
	scanf("%d%d%d", &H, &W, &D);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			scanf("%d", &A);
			px[A] = i, py[A] = j;
		}
	}
	for (int i = D + 1; i <= H * W; i++)
		d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
	scanf("%d", &Q);
	while (Q--)
	{
		scanf("%d%d", &L, &R);
		printf("%d\n", d[R] - d[L]);
	}

	return 0;
}

Measured memory_bytes: 2048
fun main() {
  val n = readLine()!!.toInt()
  val s = Array(n) { readLine()!!.reversed() }.sortedArrayWith(compareBy { it.length })
  val trie = Trie()
  var x = 0L
  for (si in s) {
    x += trie.count(si)
    trie.insert(si)
  }
  println(x)
}
class Trie {
  private var values = LongArray(26)
  private val childs = Array<Trie?>(26) { null }

  fun insert(s: String) {
    var node = this
    val length = s.length
    for (i in 0 until length - 1) {
      val c = s[i] - 'a'
      if (node.childs[c] == null) node.childs[c] = Trie()
      node = node.childs[c]!!
    }
    node.values[s[length - 1] - 'a']++
  }

  fun count(s: String): Long {
    val cnt = IntArray(26)
    for (c in s) {
      cnt[c - 'a']++
    }
    var res = 0L
    var node = this
    for (c in s) {
      for (i in cnt.indices) {
        if (cnt[i] > 0) res += node.values[i]
      }
      val n = c - 'a'
      if (node.childs[n] == null) break
      node = node.childs[n]!!
      cnt[n]--
    }
    return res
  }
}

Measured memory_bytes: 425636
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main(void) {
	lint n; cin >> n;
	lint ans;
	for (int i = 1; i < 361; i++) {
		if (i * n % 360 == 0) {
			ans = i;
			break;
		}
	}
	printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3768
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

stack = []

def bisect(li, i):
    if len(li)==0:
        li.append(i)
        return
    ok = len(li)
    ng = -1
    while abs(ok-ng)>1:
        tmp = (ok+ng)//2
        if li[tmp]<i:
            ok = tmp
        else:
            ng = tmp
    if ok < len(li):
        li[ok] = i
    else:
        li.append(i)

for i in a:
    bisect(stack, i)
print(len(stack))

Measured memory_bytes: 7832
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=1e2+2;
const int MAX_K=1e5+5;

int n,k;
int a[MAX_N];
int dp[MAX_K];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<=k;i++) dp[i]=2;
	for(int i=1;i<=k;i++) for(int j=0;j<n;j++)
		if(i-a[j]>=0)
			if(dp[i-a[j]]==2)
			{
				dp[i]=1;
				continue;
			}
	puts(dp[k]==1?"First":"Second");
	return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a;
	cin>>n>>a;
	vector<ll> x(n);
	REP(i,n) cin>>x[i];
	vector<vector<vector<ll>>> dp(n,vector<vector<ll>>(n+1,vector<ll>(2501,0)));
	dp[0][1][x[0]]=1;
	dp[0][0][0]=1;
	FOR(i,1,n) {
		REP(j,n+1) {
			REP(k,2501) {
				dp[i][j][k]=dp[i-1][j][k];
				if(j>0&&k>=x[i]) dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
			}
		}
	}
	ll ret=0;
	FOR(i,1,n+1) {
		ret+=dp[n-1][i][i*a];
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 51200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
 
int main() {
	int n,k;
	cin>>n>>k;
	vector<ll> num(k,0);
	for(int i=1;i<=n;i++) num[i%k]++;
	ll res=0;
	for(int a=0;a<k;a++){
		int b=(k-a)%k;
		int c=(k-a)%k;
		if((b+c)%k!=0) continue;
		res+=num[a]*num[b]*num[c];
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
const int MAXN = 100005;

int n, K, fa[MAXN][20], ans, dfn[MAXN], sz[MAXN], dep[MAXN], cnt;
int tot, fir[MAXN], nxt[MAXN], to[MAXN];

namespace bit {
    int sum[MAXN];
    void add(int pos, int w) {
        while (pos <= n)
            sum[pos] += w, pos += pos & (-pos);
    }
    int ask(int pos) {
        int res = 0;
        while (pos)
            res += sum[pos], pos -= pos & (-pos);
        return res;
    }
}

using bit::add;
using bit::ask;

inline void addEdge(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

void dfs(int u) {
    dep[u] = dep[fa[u][0]] + 1, dfn[u] = ++cnt, sz[u] = 1;
    for (int k = 0; k < 18; ++k)
        fa[u][k + 1] = fa[fa[u][k]][k];
    for (int i = fir[u]; i; i = nxt[i])
        dfs(to[i]), sz[u] += sz[to[i]];
}

struct cmp {
    bool operator()(const int &x, const int &y) const {
        return dep[x] < dep[y];
    }
};

priority_queue<int, vector<int>, cmp> q;

int jump(int u, int w) {
    for (int i = 18; i >= 0; --i)
        if ((w >> i) & 1) u = fa[u][i];
    return u;
}

int main() {
    cin >> n >> K;
    for (int i = 1; i <= n; ++i)
        scanf("%d", fa[i]);

    if (fa[1][0] != 1) ++ans, fa[1][0] = 1;

    for (int i = 2; i <= n; ++i)
        addEdge(fa[i][0], i);

    dfs(1);

    for (int i = 2; i <= n; ++i)
        q.push(i);

    while (!q.empty()) {
        int u = q.top(); q.pop();
        if (ask(dfn[u]) || K >= dep[u]) continue;
        int anc = jump(u, K - 1);
        if (fa[anc][0] == 1) continue;
        add(dfn[anc], 1), add(dfn[anc] + sz[anc], -1), ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 14456
#include<iostream>

using namespace std;

using ll = long long;
#define rep(i,n) for(int (i)=0; (i)<(n); ++i)


int main(){

  ll A;
  cin >> A;

  double B;
  cin >> B;

  int C = (B+0.005) *100;

  ll ans = A*C/100;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3696
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

ans = 0
g = uf.roots()
for i in g:
    ans = max(ans, uf.size(i))

print(ans)

Measured memory_bytes: 82180
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string A,B;

int main(){
    cin>>A>>B;
    if(A.length()>B.length()){
        out("GREATER");
    }
    else if(A.length()<B.length()){
        out("LESS");
    }
    else{
        rep(i,A.length()){
            if(A[i]>B[i]){
                out("GREATER");
                return 0;
            }
            else if(A[i]<B[i]){
                out("LESS");
                return 0;
            }
            else continue;
        }
        out("EQUAL");
    }
}


Measured memory_bytes: 256
s = input().strip()

is_first = True
for s1, s2 in zip(s, s[2:]):
  if s1 != s2:
    is_first = False

if is_first:
  print('Second')
else:
  if len(s) % 2 == 0:
    if s[0] == s[-1]:
      print('First')
    else:
      print('Second')
  else:
    if s[0] == s[-1]:
      print('Second')
    else:
      print('First')

Measured memory_bytes: 3316
fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn main() {
    let (n, k) = input_pair::<usize>();
    let ps = input_arr::<usize>();
    let mut m = [0; 1001];
    for i in 1..1001 {
        m[i] = m[i - 1] + i;
    }
    let ps: Vec<_> = ps.into_iter().map(|p| m[p] as f64 / p as f64).collect();
    let mut result = 0f64;
    let mut current = 0f64;
    for i in 0..n {
        current += ps[i];
        if k <= i {
            current -= ps[i - k];
        }
        if result < current {
            result = current;
        }
    }
    println!("{}", result);
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    lli n , d , r = 0 ;
    cin >> n >> d ;
    r = d * 2 + 1 ;

    if (n % r != 0)
        cout << n / r + 1 ;
    else
        cout <<  n / r  ;
        
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

string s;
int main()
{
	cin>>s;
	int len=s.size();
	char opt;
	bool flag=1;
	for (int i=0;i<len;i++)
	{
		if ((i+1)&1) opt='R';
		else opt='L';
		if (s[i]!=opt&&s[i]!='U'&&s[i]!='D')
		{
			flag=0;
			break;
		}
	}
	if (!flag) printf("No\n");
	else printf("Yes\n");
	return 0;
}


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

int main() {
  int N, A, B;
  cin >> N;

  // ここにプログラムを追記
  for (int i = 1; i < N + 1; i++){
    string x;
    cin >> x;
    if ( x == "P" || x == "W" || x == "G"){
    A += 1;
    }
    if ( x == "Y" ){
    B += 1;
    }
  } 
  if ( B == 0  ){
    cout << "Three" << endl;
  }
    else{
    cout << "Four" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define MAXN 18
using namespace std;
struct node
{
	int val1,val2;
	node(){};
	node(int _val1,int _val2):val1(_val1),val2(_val2){};
};
bool operator < (node a,node b)
{
	if(a.val1!=b.val1)
		return a.val1<b.val1;
	return a.val2<b.val2;
}
char str[2*MAXN+5];
int seed=131,MO=19260817;
map<node,int> state;
int main()
{
	int n;
	scanf("%d %s",&n,str);
	int all=(1<<n),val1,val2,cnt;
	for(int s=0;s<all;s++)
	{
		val1=0,val2=0;
		for(int i=0;i<n;i++)
			if(s&(1<<i))
				val1=(1LL*val1*seed%MO+1LL*str[i])%MO;
			else
				val2=(1LL*val2*seed%MO+1LL*str[i])%MO;
		state[node(val1,val2)]++;
	}
	for(int i=0;i<n;i++)
		str[i]=str[i+n];
	memset(str+1+n,0,sizeof(str+1+n));
	reverse(str,str+n);
	long long ans=0;
	for(int s=0;s<all;s++)
	{
		val1=0,val2=0,cnt=0;
		for(int i=0;i<n;i++)
			if(s&(1<<i))
				val1=(1LL*val1*seed%MO+1LL*str[i])%MO;
			else
				val2=(1LL*val2*seed%MO+1LL*str[i])%MO;
		if(state.find(node(val1,val2))!=state.end())
			ans+=1LL*state[node(val1,val2)];
	}
	printf("%lld\n",ans);
	return 0;
}

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

vector<int> *adj;
vector<bool> vis;
vector<int> dist;
vector<int> in_degree;
void dfs(int a) {
    vis[a] = true;
    for(int b : adj[a]) {
        dist[b] = max(dist[b], dist[a]+1);
        --in_degree[b];
        if(in_degree[b] == 0) {
            dfs(b);
        }
    }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int n, e;
    cin >> n >> e;
    adj = new vector<int>[n+1];
    vis.resize(n+1,false);
    dist.resize(n+1,0);
    in_degree.resize(n+1,0);
    for(int i=0; i<e; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].emplace_back(v);
        ++in_degree[v];
    }
   
    for(int i=1; i<=n; ++i) {
        if(!vis[i] && in_degree[i]==0) {
            dfs(i);
        }
    }
    int ans = 0;
    for(int i=1; i<=n; ++i) {
        ans = max(ans, dist[i]);
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 9600
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

int[10^^5] XS;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    foreach (i, x; readln.split.to!(int[])) {
        XS[i] = x;
    }
    int l, r = K - 1, min_res = int.max;
    while (r < N) {
        auto ld = XS[l];
        auto rd = XS[r];
        int res;
        if ((ld < 0) == (rd < 0)) {
            ld = abs(ld);
            rd = abs(rd);
            res = max(ld, rd);
        } else {
            ld = abs(ld);
            rd = abs(rd);
            res = ld > rd ? rd * 2 + ld : ld * 2 + rd;
        }
        min_res = min(min_res, res);
        ++l;
        ++r;
    }
    writeln(min_res);
}


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

delta = [0] * N
ans = 0
shortage = 0
for i in range(N):
	delta[i] = A[i] - B[i]
	if delta[i] < 0:
		ans += 1
		shortage += delta[i]

if shortage < 0:
    supply = [x for x in delta if x > 0]
    supply.sort(reverse=True)
    for i in supply:
        shortage += i
        ans += 1
        if shortage >= 0: break

if shortage >= 0:
	print(ans)
else:
	print(-1)

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

public class Main {

		
	
	public static void main(String[] args) throws Exception{
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		StringTokenizer ana = new StringTokenizer(jk.readLine()) ;
		int n =Integer.parseInt(ana.nextToken()) ; 
		double h[] = new double[n+1] ; 
		ana = new StringTokenizer(jk.readLine()) ;
		for(int i=0 ;i<n ;i++)
		{
			h[i+1]=Double.parseDouble(ana.nextToken());
		}
		double dp[][]= new double[n+1][n+1] ; 
		dp[1][0]= 1-h[1] ; 
		dp[1][1]=h[1]  ;
 		for(int i=2 ; i<=n ;i++)
		{
			double c = h[i] ; 
			dp[i][0]=(1-c)*dp[i-1][0] ; 
			for(int k= 1; k<=i ;k++)
			{
				double res= dp[i-1][k]*(1-c) + dp[i-1][k-1]*c ; 
				dp[i][k] = res ; 
			}
		}
		double res= 0 ; 
		for(int i=(n/2)+1 ; i<=n ;i++)
		{
			res+=(dp[n][i]);
		}
		out.println(res);

		



		out.flush();
	}
}



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

int main() {
  int age;
  cin >> age;
  if(age==7){
    cout << "YES" << endl;
  }else if(age==5){
    cout << "YES" << endl;
  }else if(age==3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

struct Dice {
  int label[6];
  void swap(int a, int b, int c, int d) {
    int temp = label[a];
    label[a] = label[b];
    label[b] = label[c];
    label[c] = label[d];
    label[d] = temp;
  }
  void roll(char dir) {
    switch (dir) {
    case 'N': swap(0, 1, 5, 4); break;
    case 'E': swap(0, 3, 5, 2); break;
    case 'W': swap(0, 2, 5, 3); break;
    case 'S': swap(0, 4, 5, 1); break;
    }
  }
};

int main() {
  Dice dice;
  string s;
  for (int i = 0; i < 6; i++) {
    cin >> dice.label[i];
  }
  cin >> s;
  for (auto& dir : s) {
    dice.roll(dir);
  }
  cout << dice.label[0] << "\n";
}


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

using namespace std;

int main()
{
    long long int n, k;
    cin >> n >> k;
    long long int res = n % k;
    if (res < k - res)
        cout << res << endl;
    else
        cout << k - res << endl;
    return 0;
}

Measured memory_bytes: 3504
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const ll modn = 1000000007;

int main()
{ 
    ll n, k, res = 0, sub;
    cin >> n >> k;

    for (ll i = k; i <= n + 1; i++) {
        sub = i * (n - i + 1) + 1;
        sub %= modn;
        res += sub;
        res %= modn;
    }

    cout << res << endl;

    return 0;
}


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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	string P="POSSIBLE",I="IMPOSSIBLE";
	if(n==1){
		if(a[0]==k) cout << P << endl;
		else cout << I << endl;
		return 0;
	}
	rep(i,n){
		if(a[i]==k){
			cout << P << endl;
			return 0;
		}
	}
	sort(a.begin(),a.end());
	int g=gcd(a[0],a[1]);
	rep(i,n-2){
		g=gcd(a[i+2],g);
	}
	if(k%g==0 && k<a[n-1]) cout << P << endl;
	else cout << I << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if(a+b<=2*c) cout << a*x+b*y << endl;
  else{
    if(x<=y) cout << min(2*c*x+b*(y-x), 2*c*y) << endl;
    //if(x<=y){
    else cout << min(2*c*y+a*(x-y), 2*c*x) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n;
	
	while(1){
		int e, p, q;
		int x[4001] = {0};
		int m[4001] = {0};
		
		cin >> n;
		if(n == 0) break;
		
		bool flag = true;
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			m[i] = e;
			x[e] += p * q;
			}
		
		for(int i = 1; i <= n; i++){
			if(x[m[i]] >= 1000000){
				cout << m[i] << endl;
				x[m[i]] = 0;
				flag = false;
			}
		}
		if(flag) cout << "NA" << endl;
	}
	
	return 0;
}

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

int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int t = 0;
	for(int i=0;i<k;i++){
		if(a>0){
			a-=1;
			t+=1;			
		}
		else if(b>0){
			b-=1;
			t+=0;			
		}
		else if(c>0){
			c-=1;
			t-=1;			
		}
	}
	cout << t;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t X;
  cin >> X;
  int64_t c = 100;
  for (int i = 1;i < 4000;i++){
    c *= 1.01;
  if (c >= X){
  cout << i << endl;
    break;
  }
  }
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
    int i, A, B, K;
    scanf("%d %d %d", &A, &B, &K);
    for(i=A; K!=0; i--){
        if(A%i==0 && B%i==0)K--;
    }
    printf("%d\n", i+1);
    return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
money=1000
kabu=0
for i in range(n-1):
  if a[i]<a[i+1]:
    if money<a[i]:
      continue
    kabu=money//a[i]
    money=money-a[i]*kabu
  elif a[i]==a[i+1]:
    pass
  else:
    money=money+a[i]*kabu
    kabu=0
money=money+a[-1]*kabu

print(money)

Measured memory_bytes: 61852
//D - Friends
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(int i=A;i<=B;i++)
#define BOR(i,A,B) for(int i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(int i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;
const int MAXN=2e5+10;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int Total,Side,ans=1,Pre[MAXN],Size[MAXN],a,b;

inline int Find_Fa(int New) {
	return Pre[New]==New ? New : Pre[New]=Find_Fa(Pre[New]);
}

int main() {
    //File();
	scanf("%d %d",&Total,&Side);
	FOR(i,1,Total) Pre[i] = i,Size[i] = 1;
	FOR(i,1,Side) {
		scanf("%d %d",&a,&b);
		a=Find_Fa(a);b=Find_Fa(b);
		if(a==b) continue;
		Pre[a] = b;Size[b]+=Size[a];
		ans=max(Size[b],ans);
	}
	printf("%d\n",ans);
    //fclose(stdin); fclose(stdout);
  //  system("pause");
    return 0;
}




Measured memory_bytes: 5380
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;


int main()
{
	int A, B;
	cin >> A >> B;
	if (A == B)
		cout << 0;
	else {
		if ((A + B) % 2 != 0)
			cout << "IMPOSSIBLE";
		else
			cout << (A + B) / 2;
	}
}

Measured memory_bytes: 256