akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;

int main(){
  int N;
  cin >> N ;
  long long A[N];
  rep(i,N){
    cin >> A[i];
  }
  int count=0;
  rep(i,N){
    if(A[i]%2==1){
      count += 1;
    }
  }
  if(count%2==0){
    cout << "YES" << endl;
  }else{
  cout << "NO" << endl;
  }

    return 0;
}
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep_r(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define resize(x, n) x.resize(n)
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MAX = 100000;
struct edge {
    ll from, to, weight;
    edge(ll f, ll t, ll w) : from(f), to(t), weight(w) { }
};
vector<vector<edge>> edges;
vector<vector<ll>> graph;
vector<bool> visited;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll n, m, r, answer;
ll timer = 0;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    priority_queue<pll, vector<pll>, greater<pll>> task;
    rep(i, n) {
        pll t;
        cin >> t.second; // 仕事にかかる時間
        cin >> t.first; // 締め切り        
        task.push(t);
    }
    bool flag = true;
    rep(i, n) {
        pll t = task.top();
        task.pop();
        if (timer + t.second <= t.first) {
            timer += t.second;
            // printf("完了後の時刻%lld 締め切り%lld\n", timer, t.first);
        } else {
            flag = false;
            break;
        }
    }
    if (flag) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 7408
/*+lmake
 * STD = c++14
 * DEFINE += MDEBUG
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 100000
int fa[MAXN+10];
int find(int x)
{
	if (fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void Union(int x,int y)
{
	int fx=find(x),fy=find(y);
	fa[fx]=fy;
}
void solve(long long N, long long M, vector<long long> p, vector<long long> x, vector<long long> y){
	for	(int i=1; i<=N; ++i) {
		fa[i]=i;
	}	
	for(int i=0; i<M; ++i) {
		Union(x[i],y[i]);
	}
	int ans=0;
	for(int i=1; i<=N; ++i) {
		if (find(i)==find(p[i-1])) 
			++ans;
	}
	cout<<ans<<endl;
}

int main(){	
	long long N;
	long long M;
	scanf("%lld",&N);
	vector<long long> p(N-1+1);
	scanf("%lld",&M);
	vector<long long> y(M-1+1);
	vector<long long> x(M-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&p[i]);
	}
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	solve(N, M, p, x, y);
	return 0;
}



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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for(char x : S) {
    if(x == 'x') count++;
  }
  if(count > 7) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <unordered_map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;

inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
inline ll power(ll base, ll exp)
{
	ll ans = 1;
	while (exp > 0)
	{


		if (exp % 2 != 0)
			ans = (ans * base) % N;

		base = (base * base) % N;
		exp /= 2;
	}
	return ans % N;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll m, n, sum = 0;
	cin >> n >> m;
	vector<ll> arr(n, 0);
	f(i, 0, n)
	{
		cin >> arr[i];
		sum += arr[i];
	}
	ll min = sum / (4 * m), count = 0;
	if (sum % (4 * m) != 0)
	{
		min += 1;
	}
	f(i, 0, n)
	{
		if (arr[i] >= min)
			count += 1;
	}
	if (count >= m)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A,B,K;
    cin >> A >> B >> K;
    int ans=0,c=0;
    for (int i=100; i>0; i--) {
        if (A%i==0 && B%i==0) {
            c++;
            if (c>=K) {
                ans = i;
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var n, x, ncr, p2n, mod = 998244353;
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}

console.log(main());
function main(){
  n = o.a();
  x = o.a();
  ncr = Array(n+1);
  p2n = Array(n+1);
  ncr[0] = [1];
  p2n[0] = 1;
  for(var i = 1; i <= n; i++){
    ncr[i] = Array(i+1).fill(1);
    p2n[i] = p2n[i-1] * 2 % mod;
    for(var j = 1; j < i; j++){
      ncr[i][j] = (ncr[i-1][j-1] + ncr[i-1][j]) % mod;
    }
  }
  var t = 0, ans = 1;
  if(x & 1)t = 1, ans = p2n[n];
  for(var i = 1; i <= n && i < x; i++){
    if(i * 2 < x)ans += abmod(ncr[n][i], p2n[i]-t);
    else ans += solve(i);
  }
  return ans % mod;
}
function solve(i){
  var ans = 0;
  for(var j = 0; j < x-i; j++){
    ans += abmod(ncr[n][i], ncr[i][j]);
  }
  for(var j = x-i+1; j < i; j += 2){
    ans += abmod(ncr[n][i], ncr[x-j-1][i-j]);
  }
  return ans % mod;
}

Measured memory_bytes: 69232
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math


def problem(n, a, b, c, d, e):
    return int(math.ceil(n / min(a, b, c, d, e))) + 4


def main():
    n = int(input())
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    print(problem(n, a, b, c, d, e))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    int p;
    int b[401]={0};
    for(int i=0;i<n;i++)
    {
        cin>>p;
        b[p+100]++;
    }
    if(n==0)
        cout<<x<<endl;
    else
    {
        int pr=x+100;
        int aag=x+100;
        while(1)
        {
            if(b[pr]!=0 && b[aag]==0)
            {
                cout<<aag-100<<endl;
                break;
            }
            else if(b[pr]==0 && b[aag]!=0)
            {
                cout<<pr-100<<endl;
                break;
            }
            else if((b[pr]==1 && b[aag]==1))
            {
                pr--;
                aag++;
            }
            else if(b[pr]==0 && b[aag]==0)
            {
                cout<<pr-100<<endl;
                break;
            }
        }
        }
    return 0;
}

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

int main()
{
	string S;
	cin >> S;
	for(int i=0; i<S.length(); i=i+2){
		if(S[i] == 'h' && i+1<S.length() && S[i+1] == 'i'){
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    int h, w, n, a[10005], grid[105][105] = {};
    cin >> h >> w >> n;
    for (int i = 1; i <= n; i++)cin >> a[i];
    int now = 1;
    for (int i = 0; i < h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) {
                if (a[now] >= 1) {
                    grid[i][j] = now;
                    a[now]--;
                }
                else {
                    now++;
                    grid[i][j] = now;
                    a[now]--;
                }
            }
        }
        else {
            for (int j = w-1; j >= 0; j--) {
                if (a[now] >= 1) {
                    grid[i][j] = now;
                    a[now]--;
                }
                else {
                    now++;
                    grid[i][j] = now;
                    a[now]--;
                }
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << grid[i][j]<<' ';
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s.at(0) == s.at(1)){
    if(s.at(0) != s.at(2) && s.at(2) == s.at(3))cout << "Yes" << endl; 
    else cout << "No" << endl;
  }
  else if( s.at(0) == s.at(3) && s.at(1) == s.at(2)) cout << "Yes" << endl;
  else if( s.at(0) == s.at(2) && s.at(1) == s.at(3)) cout << "Yes" << endl; 
  else cout << "No" << endl;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll k, n;
	cin >> k >> n;
	vll v(n);
	ll ans = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		if(i > 0)
			ans = max(ans, min(k - (v[i] - v[i - 1]), v[i] - v[i - 1]));
	}
	ans = max(ans, min(k - abs(v[n - 1] - v[0]), v[n - 1] - v[0]));
	cout << k - ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
  
  public static void main(String[] args) {
Scanner scanner = new Scanner (System.in);
        int N = scanner.nextInt();
        int [] arr = new int [N+1];
        for (int i = 0; i < N; i++){
            arr[i] = scanner.nextInt();
        }
        int counter = 1;
        int lastseeocean = arr[0];
        for (int i = 1; i < N; i++){
            if (arr[i] >= lastseeocean){
                counter++;
                lastseeocean = arr[i];
            }
        }
        System.out.println(counter); 
}
}

Measured memory_bytes: 35544
N = int(input())
stats = {}
for i in range(N):
  s = input()
  if s not in stats:
    stats[s] = 1
  else:
    stats[s] += 1
max = max(stats.values())
out = sorted([name for name, num in stats.items() if num == max])
for i in out:
  print(i)

Measured memory_bytes: 32988
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


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


def li(): return list(mi())


def li_(): return [int(x) - 1 for x in input().split()]


def lin(n: int): return [input() for _ in range(n)]


def llin(n: int): return [li() for _ in range(n)]


def llin_(n: int): return [li_() for _ in range(n)]


def lli(): return [list(map(int, l.split())) for l in input()]


def i(): return int(input())


def f(): return float(input())


def s(): return input().replace('\n', '')


def main():
    S = s()
    T = s()
    dp = [[0] * len(T) for _ in range(len(S))]
    dp[0][0] = int(S[0] == T[0])
    check = [[None] * len(T) for _ in range(len(S))]
    ok = (10, 10)
    check[0][0] = ok if dp[0][0] else (0, 0)
    for i in range(1, len(S)):
        if S[i] == T[0]:
            dp[i][0] = 1
            check[i][0] = ok
        else:
            dp[i][0] = dp[i - 1][0]
            check[i][0] = (-1, 0)
    for j in range(1, len(T)):
        if T[j] == S[0]:
            dp[0][j] = 1
            check[0][j] = ok
        else:
            dp[0][j] = dp[0][j-1]
            check[0][j] = (0, -1)
    for i in range(1, len(S)):
        for j in range(1, len(T)):
            if S[i] == T[j]:
                dp[i][j] = dp[i - 1][j - 1] + 1
                check[i][j] = (-1, -1)
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
                if dp[i - 1][j] > dp[i][j - 1]:
                    check[i][j] = (-1, 0)
                else:
                    check[i][j] = (0, -1)

    ans = ""
    i = len(S)-1
    j = len(T)-1
    for _ in range(len(S) + len(T)):
        if check[i][j] == ok:
            ans = S[i] + ans
            break
        else:
            if check[i][j] == (-1, -1):
                ans = S[i] + ans
                tmp = i
                i += check[i][j][0]
                j += check[tmp][j][1]
            else:
                tmp = i
                i += check[i][j][0]
                j += check[tmp][j][1]
    #print(*check, sep="\n")
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 175112
using System;
using System.Linq;
public class Test
{
    public static void Main(string[] vs)=>Console.WriteLine("{2}",vs=new string[1] {"0"}, Console.ReadLine(), new long[] { 0 }.Concat(Console.ReadLine().Split().Select(s => long.Parse(s))).Select(i => vs[0] = (long.Parse(vs[0]) + i).ToString()).GroupBy(v => v).Select(g => g.LongCount()).Where(i => i > 1).Select(i => i * (i - 1) / 2).Sum());
}

Measured memory_bytes: 68756
//include
//------------------------------------------
#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 <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	int l = s.size();
	vector<vector<LL>> dp(l+1, vector<LL>(13));
	//初期化
	if (s[0] != '?') {
		dp[0][s[0] - '0'] = 1;
	}
	else {
		for (int i = 0; i < 10; i++) {
			dp[0][i] = 1;
		}
	}

	for (int i = 1; i < l; i++) {
		for (int j = 0; j < 13; j++) {
			//数字はそのまま置くしかない
			if (s[i] != '?') {
				int v = (s[i] - '0');
				int r = (j * 10 + v) % 13;
				dp[i][r] = (dp[i][r]+dp[i - 1][j]+MOD)%MOD;
			}
			else {
				for (int k = 0; k < 10; k++) {
					int r = (j * 10 + k) % 13;
					dp[i][r] = (dp[i][r] + dp[i - 1][j] + MOD) % MOD;
				}
			}
		}
	}

	cout << dp[l-1][5] << endl;

	return 0;

}

Measured memory_bytes: 13696
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using std::min;

const int MAXN=1e3+5,MAXM=1e5+5,INF=~0U>>1;

int S,T;

struct E{int next,to,cap;} e[MAXM<<1];int ecnt=1,G[MAXN];
void addEdge(int u,int v,int c)
{
	e[++ecnt]=(E){G[u],v,c};G[u]=ecnt;
	e[++ecnt]=(E){G[v],u,0};G[v]=ecnt;
}

int dfn[MAXN];
std::queue<int> que;
bool calDfn(int u)
{
	memset(dfn,-1,sizeof dfn);
	dfn[S]=0;que.push(S);
	while(!que.empty())
	{
		int u=que.front();que.pop();
		for(int i=G[u];i;i=e[i].next) if(e[i].cap>0)
		{
			int v=e[i].to;
			if(~dfn[v]) continue;
			dfn[v]=dfn[u]+1;
			que.push(v);
		}
	}
	return ~dfn[T];
}

int iter[MAXN];
int calF(int u,int f)
{
	if(u==T) return f;
	for(int &i=iter[u];i;i=e[i].next) if(e[i].cap>0)
	{
		int v=e[i].to;
		if(dfn[v]!=dfn[u]+1) continue;
		int res=calF(v,min(f,e[i].cap));
		if(res>0)
		{
			e[i].cap-=res,e[i^1].cap+=res;
			return res;
		}
	}
	return 0;
}

int maxFlow()
{
	int f,res=0;
	while(calDfn(S))
	{
		memcpy(iter,G,sizeof G);
		while(f=calF(S,INF)) res+=f;
	}
	return res;
}

int n;
struct P{int x,y;} red[MAXN],blue[MAXN];

int main()
{
	int i,j;scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d%d",&red[i].x,&red[i].y);
	for(i=1;i<=n;i++) scanf("%d%d",&blue[i].x,&blue[i].y);
	S=n<<1|1,T=S+1;
	for(i=1;i<=n;i++) addEdge(S,i,1);
	for(i=1;i<=n;i++) addEdge(i+n,T,1);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(red[i].x<blue[j].x&&red[i].y<blue[j].y)
				addEdge(i,n+j,1);
	printf("%d",maxFlow());
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

main(){
  int n;        /* This n is number of scanning integer.*/
  int s;        /* This s is to substitute scanning integer.*/
  int counter=0,i,j;

  scanf("%d",&n);
  if(n<1||n>10000){
    return 0;
  }             /* Constraints: 1<=n<=10000 */
  
  for(i=n;i>0;i--){
    scanf("%d",&s);  /* Scanning integer */
    if(s<2||s>10e8){
      return 0;
    }           /* Constraints: 2<=an element of the list<=10e8 */

    if(s==2){
      counter++;
      continue;
    }
    else if(s%2==0)continue;
    for(j=3;j<sqrt((double)s);j+=2){
      if(s%j==0)break;
    }           /* Judging that s is prime or not */
    if(j>sqrt((double)s))counter++;
  }

  printf("%d\n",counter);  /* Printing number of prime */
  return 0;
}

Measured memory_bytes: 0
D, N = map(int, input().split())
if D == 0:
    if N < 100:
        print(N)
    else:
        print(101)
elif D == 1:
    if N < 100:
        print(N * 100)
    else:
        print(N * 100 + 100)
else:
    if N < 100:
        print(N * 10000)
    else:
        print(N * 10000 + 10000)

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

const int MAX_N=10e4+5;
int n,cntr[MAX_N],cntg[MAX_N],cntb[MAX_N];
ll ans;
string s;

char neg(char a,char b){
 if(a=='R' && b=='G'){return 'B';}
 if(a=='R' && b=='B'){return 'G';}
 if(a=='G' && b=='R'){return 'B';}
 if(a=='B' && b=='R'){return 'G';}
 if(a=='B' && b=='G'){return 'R';}
 if(a=='G' && b=='B'){return 'R';}
 return 'h';
}

int main(){
  cin >> n;
  cin >> s;
  cntr[0]=(s[0]=='R');
  cntg[0]=(s[0]=='G');
  cntb[0]=(s[0]=='B');
  for(int i=0;i<n;++i){
    cntr[i]=cntr[i-1]+(s[i]=='R');
    cntg[i]=cntg[i-1]+(s[i]=='G');
    cntb[i]=cntb[i-1]+(s[i]=='B');
  }

  for(int i=0;i<n;++i){
    for(int k=i+3;k<n;++k){

        if(neg(s[i],s[k])=='R'){
            ans+=cntr[k-1]-cntr[i];
        }
        if(neg(s[i],s[k])=='G'){
            ans+=cntg[k-1]-cntg[i];
        }
        if(neg(s[i],s[k])=='B'){
            ans+=cntb[k-1]-cntb[i];
        }
        if((k-i)%2==0){
            ans-=s[(i+k)/2]==neg(s[i],s[k]);
        }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3696
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = new long[n];
			int minusCount = (int) IntStream.range(0, n).mapToLong(i -> a[i] = scanner.nextLong()).filter(ai -> ai < 0)
					.count();
			long sum = Arrays.stream(a).map(Math::abs).sum();
			System.out.println(
					(1 == (minusCount & 1)) ? sum - 2 * Arrays.stream(a).map(Math::abs).min().getAsLong() : sum);
		}
	}
}


Measured memory_bytes: 60784
N=int(input())
F=[int(input().replace(' ',''),2) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]
print(max(sum([p[bin(f&i).count('1')] for f,p in zip(F,P)]) for i in range(1,2**10)))

Measured memory_bytes: 3064
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> p = new HashSet<Integer>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}

		boolean flag = true;
		int ans;
		int i = 0;
		while (flag) {
			ans = x - i;
			if (!p.contains(ans)) {
				System.out.println(ans);
				flag = false;
				break;
			}
			ans = x + i;
			if (!p.contains(ans)) {
				System.out.println(ans);
				flag = false;
				break;
			}
			i++;
		}

		sc.close();
	}

}


Measured memory_bytes: 35912
#include<cstdio>
#include<map>
using namespace std;
int n,k,l;
int fg[200000],ft[200000];
map<pair<int,int>,int> s;
int findg(int x)
{
	if(fg[x]!=x) fg[x]=findg(fg[x]);
	return fg[x];
}
void ug(int r1,int r2)
{
	fg[r2]=r1;
}
int findt(int x)
{
	if(ft[x]!=x) ft[x]=findt(ft[x]);
	return ft[x];
}
void ut(int r1,int r2)
{
	ft[r2]=r1;
}
int main()
{
	int r1,r2;
	scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;i++) fg[i]=ft[i]=i;
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d",&r1,&r2);
		r1=findg(r1);
		r2=findg(r2);
		if(r1!=r2) ug(r1,r2);
	}
	for(int i=1;i<=l;i++)
	{
		scanf("%d%d",&r1,&r2);
		r1=findt(r1);
		r2=findt(r2);
		if(r1!=r2) ut(r1,r2);
	}
	for(int i=1;i<=n;i++)
	{
		findg(i);
		findt(i);
	}
	
	for(int i=1;i<=n;i++)
	{
		s[{fg[i],ft[i]}]++;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d ",s[{fg[i],ft[i]}]);
	}
	return 0;
}

Measured memory_bytes: 13568
#include<stdio.h>
#include<math.h>

int main()
{
	int i,n,s,t=0;
	double a,m=0;
	
	while(1){
		t=0;
		m=0;
		scanf("%d",&n);
		if(n==0) break;
		
		for(i=0;i<n;i++){
			scanf("%d",&s);
			
			m += s;	
			t += s*s;
		}
	
		a=sqrt(((double)t/n)-pow(m/n,2));
	
		printf("%f\n",a);
	}
	return 0;
}


Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var A = input[0];
            var B = input[1];
            var K = input[2];

            if (A + K - 1 <= B)
            {
                for (var i = A; i < A + K; i++) Console.WriteLine(i);
            }else
            {
                for (var i = A; i <= B; i++) Console.WriteLine(i);
            }

            if (B - K + 1 > A + K - 1)
            {
                for (var i = B - K + 1; i <= B; i++) Console.WriteLine(i);
            }else
            {
                for (var i = A + K; i <= B; i++) Console.WriteLine(i);
            }
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define For(i, j, k) for (int i = j; i <= k; i++)
using namespace std;
const int N = 2e5 + 10;
int n; int pa[N], fa[N], w[N]; int c0[N], c1[N];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
struct Node { int o, x, y; bool operator < (const Node B) const { return 1ll * y * B.x > 1ll * x * B.y; } };
priority_queue<Node> q;
int main() {
	scanf("%d", &n);
	For(i, 2, n) scanf("%d", &pa[i]);
	For(i, 1, n) { scanf("%d", &w[i]), fa[i] = i; c0[i] = !w[i], c1[i] = w[i]; if (i > 1) q.push((Node){i, c0[i], c1[i]}); }
	long long ans = 0;
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int o = find(s.o); if (c0[o] != s.x || c1[o] != s.y) continue;
		int f = find(pa[o]); ans += 1ll * c1[f] * c0[o]; fa[o] = f, c0[f] += c0[o], c1[f] += c1[o];
		if (f != 1) q.push((Node){f, c0[f], c1[f]});
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8304
/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

// VJUDGE

const int N = 105, M = 100 * 1001, MOD = 1e9 + 7;
int n, a[N], k, dp[M][N], sum[M][N];

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i <= k; i++) {
		if (i <= a[0]) 
			dp[i][0] = 1;
		sum[i][0] = ((i ? sum[i - 1][0] : 0) + dp[i][0]) % MOD;
//			cout << i << " 0 " << dp[i][0] << endl;
	}
	for (int i = 0; i <= k; i++)
		for (int j = 1; j < n; j++) {
			//dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1] + ... + dp[i - a[j]][j - 1];
			dp[i][j] = (sum[i][j - 1] - (i - a[j] - 1 >= 0 ? sum[i - a[j] - 1][j - 1] : 0) + MOD) % MOD;
			sum[i][j] = ((i ? sum[i - 1][j] : 0) + dp[i][j]) % MOD; 
//			cout << i << " " << j << " ** " << dp[i][j] << " /*-/- " << sum[i][j] << endl;
		}
/*	cout << sum[2][0] << " " << sum[1][0] + dp[2][0] << "/\n";
	for (int i = 0; i <= k; i++)
		for (int j = 0; j < n; j++) 
			cout << i << "  " << j << " ==  " << dp[i][j] << "   SUM  " << sum[i][j] << endl;*/
	cout << dp[k][n - 1] << endl;
}


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

import static java.lang.Math.*;

public class Main {
  public static void main(String[] args) {
    new Main().solve();
  }

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      final int n = in.nextInt();
      List<Pear> task = new ArrayList<>(n);
      for (int i = 0; i < n; i++) {
        task.add(new Pear(in.nextInt(), in.nextInt()));
      }

      // Collections.sort(task);
      task.sort((a,b) -> a.compareTo(b));

      boolean isComp = true;
      int time = 0;
      for (Pear p : task) {
        time += p.c;
        if(time > p.l) {
          isComp = false;
          break;
        }
      }

      String ans = isComp ? "Yes" : "No";
      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  

  private class Pear implements Comparable<Pear>{
    public int c,l;
    Pear(int c, int l) {
      this.c = c;
      this.l = l;
    }

    @Override
    public int compareTo(Pear o) {
      if(o == null) throw new NullPointerException();
      return l == o.l ? 0 : l - o.l;
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  static class InputReader implements AutoCloseable {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

Measured memory_bytes: 53044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long int ll;
typedef vector<long long int> vi;

int main(){
	vi v;
	ll m;
	REP(i, 10){
		cin >> m;
		v.push_back(m);
	}
	sort(ALL(v));
	REP(i, 3){
		cout << v[9-i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;

bool hate[10];

bool safe(int i){
	while(i > 0){
		if(hate[i%10]) return false;
		i /= 10;
	}
	return true;
}

int main(){
	int n, k;
	cin >> n >> k;
	
	for(int i = 0;i < 10;i++) hate[i] = false;
	for(int i = 0;i < k;i++){
		int d;
		cin >> d;
		hate[d] = true;
	}
	
	for(int i = n;;i++){
		if(safe(i)){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

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

int Fibonacci( int n, std::vector<int>& v ){
    if( !n || n == 1 ){
        if( !v[n] ){
            v[n] = 1;
        }
        return v[n];
    }else{
        if( !v[n] ){
            v[n] = Fibonacci( n-1, v ) + Fibonacci( n-2, v );
        }
        return v[n];
    }
}

int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;

    std::vector<int> fib(n+1, 0);
    
    std::cout << Fibonacci( n, fib ) << std::endl;
}


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

const int MAXN = 3010;

string s,t;
int dp[MAXN][MAXN],N,M;
stack<char> resposta;

int solve(int a,int b){

	if(a < 0 || b < 0) return 0;

	if(dp[a][b] != -1) return dp[a][b];

	if(s[a] == t[b]) return dp[a][b] = 1 + solve(a-1,b-1);

	return dp[a][b] = max(solve(a-1,b),solve(a,b-1));

}

void build(int a,int b){

	if(a < 0 || b < 0) return;

	if(s[a] == t[b]){
		resposta.push(s[a]);
		build(a-1,b-1);
		return;
	}

	if(solve(a-1,b) > solve(a,b-1)) build(a-1,b);
	else build(a,b-1);

}

int main(){

	memset(dp,-1,sizeof(dp));

	cin >> s;
	cin >> t;

	N = (int)s.size();
	M = (int)t.size();

	build(N-1,M-1);

	while(!resposta.empty()){
		cout << resposta.top();
		resposta.pop();
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 39256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
ll repeatsquaring(ll N,ll M,ll P){
  if(M==0)return 1;
  if(M%2==0){
    ll t=repeatsquaring(N,M/2,P);
    return t*t%P;
  }
  return M*repeatsquaring(N,M-1,P);
}
int main(){
  ll N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  ll ans=0;
  for(int i=0;i<60;i++){
    ll one=0;
    for(int j=0;j<N;j++){
      if(A[j]>>i&1)one++;
    }
    ll zero=N-one;
    ll now=zero*one%MOD;
    for(int j=0;j<i;j++)now=now*2%MOD;   
    ans+=now;
    ans=ans%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def dfs(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのstackを作成
    dist[start] = 0
    stack = [(0,start)]
    
    while stack:
        cost, cur_node = stack.pop()

        # 未探索のノードをstackに入れる
        for nex_cost, nex_node in graph[cur_node]:
            if dist[nex_node] != INF:
                continue
            else:
                dist[nex_node] = dist[cur_node] + nex_cost
                stack.append((dist[nex_node],nex_node))
                
    return dist

n,m = li()
edges = []
INF = float("inf")

for _ in range(m):
    a,b = li_()
    edges.append((a,b))
    
ans = 0
for i in range(m):
    graph = graph = [[] for _ in range(n)]
    for j in range(m):
        if i != j:
            graph[edges[j][0]].append((1,edges[j][1]))
            graph[edges[j][1]].append((1,edges[j][0]))
            
    dist = dfs(graph, n, 0)
    
    if INF in dist:
        ans += 1
        
        
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 2e5 + 5;

int n, a[N];
				
int32_t main() {
	fast_cin();  

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a, a + n);
	int ans = 0;
	int b;
	b = a[n / 2];
	for (int i = 0; i < n; i++)
		ans += (abs(a[i] - b));
	cout << ans << endl;

	return 0;
}

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

signed main()
{
    int L,R; cin>>L>>R;
    if(R-L+1>=2019){
        cout<<0<<endl;
        return 0;
    }
    int ans=2019;
    for(int i=L;i<R;i++){
        for(int j=i+1;j<=R;j++){
            ans=min(ans,i*j%2019);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a[200000],n,i,j,r,min,max;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  min = a[0];
  max = a[1] - a[0];
  for(i=1;i<n;i++){
    if(max<a[i]-min) max = a[i] - min;
    if(a[i]<min) min = a[i];
  }
      printf("%d\n",max);
  return 0;
}



Measured memory_bytes: 2488
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int Q=gi();
	    int[] L=new int[Q];
	    int[] R=new int[Q];

	    int max=0;
	    for (int i=0; i<Q;i++) {
	    	L[i]=gi();
	    	R[i]=gi();
	    	max=Math.max(max, R[i]);
	    }

	    boolean[] isP=new boolean[max+1];

	    for (int i=2; i<(max+1);i++) {
	    	isP[i]=true;
	    }
	    for (int i=2; i<(max+1)/2;i++) {
	    	if(isP[i]) {
	    		int v=i;
	    		while(v+i<max+1) {
	    			v+=i;
	    			isP[v]=false;
	    		}
	    	}
	    }

	    int[] pn=new int[max+1];
	    int n=0;
	    for (int i=1; i<max+1;i++) {
	    	if(i%2==1 && isP[i] && isP[(i+1)/2])n++;
	    	pn[i]=n;
	    }

	    for(int i=0; i<Q;i++) {
	    	System.out.println(pn[R[i]]-pn[L[i]-1]);
	    }
        //System.out.println(ans);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 60752
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a1 = scan.nextInt();
        int a2 = scan.nextInt();
        int a3 = scan.nextInt();
        int a4 = scan.nextInt();
        boolean[] digits = new boolean[10];
        digits[a1] = true;
        digits[a2] = true;
        digits[a3] = true;
        digits[a4] = true;
        if (digits[1]&&digits[4]&&digits[7]&&digits[9]) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<bool> a(10, false), b(100, false);
    vector<bool> ans(1000);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 100; j++) {
            if (b[j]) {
                ans[j * 10 + (s[i] - '0')] = true;
            }
        }
        for (int j = 0; j < 10; j++) {
            if (a[j]) {
                b[j * 10 + (s[i] - '0')] = true;
            }
        }
        a[s[i] - '0'] = true;
    }
    int r = 0;
    for (int i = 0; i < 1000; i++) {
        if (ans[i]) {
            r++;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
a, b = map(int, input().split())
ins = int(str(a) + str(b))
myInt = math.sqrt(ins)
print('{}'.format('Yes' 
                  if isinstance(myInt, int) 
                  else 'Yes' 
                  if myInt.is_integer()
                  else 'No'
                 )
     )

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

int main()
{
    std::string s;
    int sum;
    while (1) {
        sum = 0;
        std::cin >> s;
        if (s[0] == '0') break;
        for (int i = 0; i < s.size(); i++) {
            sum += int(s[i] - '0');
        }
        std::cout << sum << std::endl;
    }
}


Measured memory_bytes: 3148
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){
  int h;
  cin>>h;
  int w;
  cin>>w;
  vector<string>a(h);
  for(int i=0;i<h;i++){
    cin>>a[i];
  }

 vector<bool>row(h, false);
 vector<bool>col(w,false);
 for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
         if(a[i][j]=='#'){
               row[i]=true;
               col[j]=true;
         }
     }
 }

      for(int i=0;i<h;i++){
        if(row[i]){
          for(int j=0;j<w;j++){
            if(col[j]){
              cout<<a[i][j];
            }
          }
cout<<endl;

        }
      }

}
  


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int h,w,i,j,x[1000000],y[1000000],c=0,s=0,e=0,r=0;
    char a[1000][1001];
    scanf("%d%d",&h,&w);
    for(i=0;i<h;i++){
        scanf("%s",a[i]);
        for(j=0;j<w;j++){
            if(a[i][j]=='#'){
                x[e]=i;
                y[e]=j;
                e++;
            }
        }
    }
    if(e==h*w){
        puts("0");
        return 0;
    }
    while(e!=h*w){
        if(s==c){
            c=e;
            r++;
        }
        if(x[s]-1>=0&&a[x[s]-1][y[s]]=='.'){
            a[x[s]-1][y[s]]='#';
            x[e]=x[s]-1;
            y[e]=y[s];
            e++;
        }
        if(x[s]+1<h&&a[x[s]+1][y[s]]=='.'){
            a[x[s]+1][y[s]]='#';
            x[e]=x[s]+1;
            y[e]=y[s];
            e++;
        }
        if(y[s]-1>=0&&a[x[s]][y[s]-1]=='.'){
            a[x[s]][y[s]-1]='#';
            x[e]=x[s];
            y[e]=y[s]-1;
            e++;
        }
        if(y[s]+1<w&&a[x[s]][y[s]+1]=='.'){
            a[x[s]][y[s]+1]='#';
            x[e]=x[s];
            y[e]=y[s]+1;
            e++;
        }
        s++;
    }
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 8960
N = int(input())
d,ub = 0,0
for i in range(N):
    s = (i+1)*(i+2)//2
    if s>=N:
        d = s-N
        ub = i+1
        break
for i in range(ub):
    if i+1!=d:
        print(i+1)


Measured memory_bytes: 42456
a=int(input())
b=int(input())
c=int(input())
x=int(input())
shurui = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      goukei=500*i+100*j+50*k
      if goukei == x:
        shurui +=1
print(shurui)

Measured memory_bytes: 9108
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int yy = a / 100;
        int mm = a % 100;
        int ans = 0;
        boolean yyyy = false;
        if (0 < yy && yy < 13) {
            ans++;
            yyyy = true;

        }
        if (0 < mm && mm < 13) {
            ans++;
        }
        String mes = "NA";
        if (ans == 2) {
            mes = "AMBIGUOUS";
        } else if (ans == 1) {
            if (!yyyy) {
                mes = "YYMM";
            } else {
                mes = "MMYY";
            }
        }
        System.out.println(mes);
        sc.close();
    }
}

Measured memory_bytes: 21844
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, n; cin >> h >> w >> n;
    vvll obstacle(h);
    REP(i, n) {
        ll x, y; cin >> x >> y;
        obstacle[x - 1].emplace_back(y - 1);
    }
    ll tmp = 0, left = 0, right = 1;
    while (true) {
        if (tmp + 1 >= h) break;
        sort(ALL(obstacle[tmp + 1]));
        if (obstacle[tmp + 1].empty()) {
            tmp++, right++;
        } else {
            if (obstacle[tmp + 1][0] < right) break;
            else {
                right = min(right + 1, obstacle[tmp + 1][0]);
                tmp++;
            }
        }
    }

    cout << tmp + 1 << '\n';
    return 0;
}


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

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

	sort(v.begin(), v.end());
	double ans = 0;
	for (int i = 0; i < n; i++) {
		if (i == 0) ans += (double)v[i] / (double)pow(2, n - 1);
		else ans += (double)v[i] / (double)pow(2, n - i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskL solver = new TaskL();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskL {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = in.nextInt();
            long[][] dp = new long[n + 1][n + 1];
            long[] sum = new long[n + 1];
            sum[0] = 0;
            for (int i = 0; i < n; i++)
                sum[i + 1] = sum[i] + arr[i];
            for (int j = 0; j < n; j++) {
                for (int i = j; i >= 0; i--) {
                    if (i == j) {
                        dp[i][j] = arr[i];
                    } else {
                        dp[i][j] = Math.max(sum[j + 1] - sum[i + 1] - dp[i + 1][j] + arr[i], sum[j] - sum[i] - dp[i][j - 1] + arr[j]);
                    }
                }
            }
            out.println(2 * dp[0][n - 1] - sum[n]);
        }

    }
}



Measured memory_bytes: 129784
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define x first
#define y second

using namespace std;

const string FILENAME = "input";

int main(int argc, char const *argv[])
{
	int a, b, c; cin >> a >> b >> c;
	cout << max(a, max(b, c)) - min(a, min(b, c)) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;


void solve(long long H){
    long long count = 0;
    if(H==1)cout<<"1"<<endl;
    else{
        while(1){
            H = H/2;
            count++;
            if(H==1)break;
        }
        long long ans = 0;
        for(int i=0;i<=count;i++){
            ans += pow(2, i);
        }
        cout<<ans<<endl;
    }
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
import bisect
primes = [0, 0] + [1] * 32767
for i in range(2, 182):
    if primes[i]:
        for j in range(i*i, 32769, i):
            primes[j] = 0

prime_values = [i for i, v in enumerate(primes) if v]
while True:
    n = int(input())
    if n == 0:
        break
    eov = bisect.bisect(prime_values, n//2)
    print(sum(primes[n-p] for p in prime_values[:eov]))



Measured memory_bytes: 6052