akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private final static int SIZE = 8;
	
	private final static int[][] MOVABLE_PAIRS = {
		{1,4}, {0,2,5}, {1,3,6}, {2,7},
		{0,5}, {1,4,6}, {2,5,7}, {3,6}
	};
	
	private final static int[] coefficients = {5040, 720, 120, 24, 6, 2, 1, 0};

	private static final int[] ANSWER_STATE = {0,1,2,3,4,5,6,7};
	
	private static final int FORE_DIRECTION = 1;
	private static final int BACK_DIRECTION = -1;
	
	private Main() {
		Scanner in = new Scanner(System.in);
		
		while(in.hasNext()) {
			int[] puzzle = new int[SIZE];
			for(int i=0; i<SIZE; i++) {
				puzzle[i] = in.nextInt();
			}
			System.out.println(solve(puzzle));
		}
		in.close();
	}
	
	final class Puzzle {
		final int[] state;
		final int depth;
		final int movablePiecePoint;
		final int point;
		final boolean isRoot;
		int stateCode;
		final int direction;
		
		public Puzzle(int[] state, int direction) {
			this.isRoot = true;
			this.depth = 0;
			this.state = state;
			this.point = -1;
			this.direction = direction;
			setStateCode();
			
			for(int i=0; i<SIZE; i++) {
				if(state[i]==0) {
					this.movablePiecePoint = i;
					return;
				}
			}
			this.movablePiecePoint = -1;
		}
		
		public Puzzle (Puzzle parent, int nextMove){
			this.isRoot = false;
			this.depth = parent.depth+1;
			this.point = parent.movablePiecePoint;
			this.movablePiecePoint = nextMove;
			this.direction = parent.direction;
			
			this.state = Arrays.copyOf(parent.state, SIZE);
			this.state[this.point] = this.state[nextMove];
			this.state[nextMove] = 0;

			setStateCode();
		}
		
		private final void setStateCode() {
			for(int i=0; i<SIZE-1; i++) {
				int c = 0;
				for(int j=i+1; j<SIZE; j++) {
					if(this.state[i] > this.state[j]) {
						c++;
					}
				}
				this.stateCode += coefficients[i]*c;
			}
		}
	}
	
	private final int solve(int[] puzzle) {
		int[] isVisit = new int[50430];
		ArrayDeque<Puzzle> queue = new ArrayDeque<Puzzle>();
		queue.add(new Puzzle(puzzle, FORE_DIRECTION));
		queue.add(new Puzzle(ANSWER_STATE, BACK_DIRECTION));
		while(!queue.isEmpty()) {
			Puzzle now = queue.poll();
			if(now.stateCode==0 && now.direction==FORE_DIRECTION) {
				return now.depth;
			} else if(isVisit[now.stateCode]!=0 && isVisit[now.stateCode]*now.direction<0) {
				return now.depth + StrictMath.abs(isVisit[now.stateCode]);
			}
			for(int nextMove : MOVABLE_PAIRS[now.movablePiecePoint]) {
				if (now.isRoot || now.point!=nextMove) {
					queue.add(new Puzzle(now, nextMove));
				}
			}
			isVisit[now.stateCode] = now.direction*now.depth;
		}
		return -1;
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

Measured memory_bytes: 16000
import java.util.Arrays;
import java.util.Random;

//The Closest Circle
public class Main{

	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
	
	class R implements Comparable<R>{
		double x, y, r;
		public R(double x, double y, double r) {
			this.x = x;
			this.y = y;
			this.r = r;
		}
		public int compareTo(R o) {
			if(Math.abs(x-o.x)<EPS)return (int)Math.signum(y-o.y);
			return (int)Math.signum(x-o.x);
		}
	}
	
	double EPS = 1e-8;
	
	void run(){
		Scanner sc = new Scanner();
		Random rand = new Random(System.currentTimeMillis());
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int rot = rand.nextInt(44)+1;
			double sin = Math.sin(rot*Math.PI/180), cos = Math.cos(rot*Math.PI/180);
			R[] rs = new R[n];
			for(int i=0;i<n;i++){
				double r = sc.nextDouble(), x = sc.nextDouble(), y = sc.nextDouble();
				rs[i] = new R(cos*x-sin*y, sin*x+cos*y, r);
			}
			Arrays.sort(rs);
			double res = 1L<<60;
			for(int i=0;i<n;i++){
				int t = Math.min(n, i+10);
				for(int j=i+1;j<t;j++){
					res = Math.min(res, Math.sqrt((rs[i].x-rs[j].x)*(rs[i].x-rs[j].x) + (rs[i].y-rs[j].y)*(rs[i].y-rs[j].y))-rs[i].r-rs[j].r);
				}
			}
			System.out.printf("%.9f\n", res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 19000
function readInt(str){
    return parseInt(str, 10);
}
function range(begin, end){
    if(begin > end) return range(end, begin).reverse();
    const ans=[];
    for(let i=begin; i<=end; i++){
        ans.push(i);
    }
    return ans;
}
function div(y, x){
    return Math.floor(y/x);
}
function nth(value, n, base){
    return div(value, Math.pow(base, n))%base;
}
function calc(N,A,B,C,l,pattern){
    const leng=[0,0,0];
    let cost=-30;
    let used=[0,0,0];
    for(const i of range(0,N-1)){
        switch(pattern[i]){
            case 0:
            case 1:
            case 2:
                leng[pattern[i]]+=l[i];
                cost+=10;
                used[pattern[i]]=1;
                break;
            case 3:break;
        }
    }
    if(used[0]==1 && used[1]==1 && used[2]==1) 
    return cost+Math.abs(A-leng[0])+Math.abs(B-leng[1])+Math.abs(C-leng[2]);
    return Infinity;
}
function solve(N,A,B,C,l){
    let pattern = new Array(N);
    let min=Infinity;
    for(const i of range(0, Math.pow(4, N)-1)){
        pattern = range(0,N-1).map(n=>nth(i,n,4));
        let ans =calc(N,A,B,C,l,pattern);
        // console.error(ans, N,A,B,C,l,pattern);
        min=Math.min(ans,min);
    }
    return min;
}

function Main(raw) {
    const [NABC,...L] = raw.split("\n");
    const [N,A,B,C] = NABC.split(" ").map(readInt);
    const l = L.map(readInt);
    // console.log(calc(N,A,B,C,l,[0,1,1,1,2]));
    //出力
    console.log("%d", solve(N,A,B,C,l));
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 15216
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define lowbit(x) (x& -x)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0';
    return tmp*f;
}
using namespace std;
int a[100010];
int n;
int main()
{
	int i;
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	int ansx=a[2],ansy=a[1],now=1;
	for(i=3;i<=n;i++){
		int mx=(a[i]+1)/2;
		while(now<i&&abs(a[now]-mx)>abs(a[now+1]-mx))now++;
		ansx=a[i],ansy=a[now];
	}
	printf("%d %d\n",ansx,ansy);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){

  int n,a[3]={},tmp,r=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(tmp%3==0) a[0]++;
    else if(tmp%3==1) a[1]++;
    else a[2]++;
  }
  if(a[1]==0&&a[2]==0){
    cout<<"1"<<endl;
    return 0;
  }
  r=abs(a[1]-a[2]);
  if(r>3) r=3;
  a[1]=min(a[1],a[2]);
  cout<<a[0]+a[1]*2+r<<endl;
  return 0;
}

Measured memory_bytes: 3096
#include <cstdio>
using namespace std;

int main()
{

	int a, b;

	scanf( "%d %d", &a, &b );
	printf( "%d %d %lf\n", a / b, a % b, static_cast< double >(a) / static_cast< double >(b) );

	return 0;

}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
using namespace std;
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 << std::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
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , k;
    cin >> n >> k;
    if(k == 1)
        cout << 0 << endl;
    else if(n == k)
        cout << 0 << endl;
    else
    {
        cout << n-k << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
x = list(map(int, input().split()))
for i in range(len(x)):
    min = i
    for j in range(i + 1, len(x)):
        if x[min] > x[j]:
            min = j
    x[min], x[i] = x[i], x[min]
print(x[0], x[1], x[2])



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

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

const int N = 2e5 + 5;
int dp[N], h[N], a[N], n;
int tree[N << 2];

void update(int node, int st, int en, int pos, int val)
{
   if(st == en)
   {
      tree[node] = max(tree[node], val);
      return;
   }

   int mid = (st + en) / 2;
   if(pos <= mid)
     update(2 * node, st, mid, pos, val);
   else
     update(2 * node + 1, mid + 1, en, pos, val);

   tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}

int query(int node, int st, int en, int l, int r)
{
   if(st > r || en < l || l > r)
      return INT_MIN;

   if(l <= st && en <= r)
     return tree[node];

   int mid = (st + en) / 2;
   int left = query(2 * node, st, mid, l, r);
   int right = query(2 * node + 1, mid + 1, en, l, r);
   return max(left, right);
}


int32_t main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
 
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> h[i];

  for(int i = 1; i <= n; i++)
    cin >> a[i];

  

  for(int i = 1; i <= n; i++)
  {
    int prev = query(1, 1, n, 1, h[i] - 1);
    dp[h[i]] = max(a[i], a[i] + prev);
    update(1, 1, n, h[i], dp[h[i]]);
  }

  int ans = 0;

  for(int i = 1; i <= n; i++)
    ans = max(ans, dp[i]);

  cout << ans;

  return 0;
}

Measured memory_bytes: 11264
import fractions
a,b,c,d=map(int,input().split())
bc=b//c
ac=(a-1)//c
bd=b//d
ad=(a-1)//d
bcd=b//((c*d)//fractions.gcd(c,d))
acd=(a-1)//((c*d)//fractions.gcd(c,d))
r=b-a+1
print(r-((bc-ac)+(bd-ad)-(bcd-acd)))

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

const int  maxn = 100002;

int par[maxn];
int ranks[maxn];
int club[maxn];

void init(){//初期化
    for(int i=0;i<maxn;i++){
        par[i] = i;
        ranks[i] = 0;
    }
}

int find(int x){//探索
    if(par[x] == x){
        return x;
    } else{
        return par[x] = find(par[x]);
    }
}

void unite(int x,int y){//連結
    x = find(x);
    y = find(y);
    if(x == y ) return;

    if(ranks[x] < ranks[y]){
        par[x] = y;
        if(club[y] == 0 && club[x] != 0){
            club[y] = club[x];
        }
    }
    else{
        par[y] = x;
        if(club[x] == 0 && club[y] != 0){
            club[x] = club[y];
        }
        if(ranks[x] == ranks[y])
            ranks[x]++;
    }
}

int p[maxn];


int main() {

    int n,m;

    cin >> n >> m;

    for(int i=0; i<n; i++){
        cin >> p[i];
    }

    int x,y;

    init();

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

        scanf(" %d %d", &x, &y);

        unite(x,y);

    }

    int ans = 0;

    for(int i=1; i<=n; i++){
        if(find(p[i-1]) == find(i)){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    string ans = "";
    for (auto c : s)
    {
        if (c == 'B')
        {
            if (!ans.empty())
            {
                ans.pop_back();
            }
        }
        else
        {
            ans += c;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    double x,y,h,w;
    scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
    printf("%f ",h*w/2);
    if(x==w/2&&y==h/2){
        printf("1\n");
    }
    else{
        printf("0\n");
    }
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long K = sc.nextLong();
    //一個目はK色、２個目以降は前の色以外のK-1色から選択
    if(N==1){
      System.out.println(K);
      return;
    }
    long answer = K*(long)Math.pow(K-1,N-1);
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
#define print(ans) cout << fixed << setprecision(15) << ans << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, K;
string S;

int main() {
  cin >> N >> K;
  vi h(N);
  rep(i, N){
    cin >> h[i];
  }
  int ans = 0;
  rep(i, N){
    if (h[i] >= K){
      ans++;
    }
  }
  print(ans);
}

Measured memory_bytes: 3892
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
int main(void){
	//(部分点はRMQ)
	//スライド最大値₯
	//O(NK)
	llint n,m,K,i,j,ans=0;cin>>n>>m>>K;
	vector<llint>dp(n);
	vector<llint>pot(n);
	for(i=0;i<n;i++){cin>>pot[i];}
	for(i=1;i<=K;i++){
		deque<pair<int,llint>>slide;
		if(i==1){slide.pub(mp(0,0LL));}
		for(j=0;j<n;j++){
			llint mot=dp[j];
			if(slide.size()>0&&slide.front().fir<j-m){slide.pof();}
			if(i-1<=j){
				dp[j]=slide.front().sec+i*pot[j];
				maxeq(ans,dp[j]);
			}
			while(slide.size()>0&&slide.back().sec<=mot){slide.pob();}
			slide.pub(mp(j,mot));
			
			//cerr<<dp[j]<<" ";
		}
		//cerr<<endl;
	}
	cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

const int MAX_N = 200000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}


int main(){
    ll N, K;
    cin >> N >> K;

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ll ans = 0;
    REP(k, min(N, K)+1){
        ll add = comb(N, k) * comb(N-1, k);
        add %= MOD;
        ans += add;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

struct ans {
	int from, to; string cost;
};
vector<ans> v;
bool exi[301][301];
void solve() {

	int a, b; cin >> a >> b;
	int d[11][11];
	rep1(i, a) {
		rep1(j, b) {
			cin >> d[i][j];
		}
	}
	bool valid = true;
	int s = 1, t = 202, cur = 3;
	Rep1(i, 2, 101) {
		v.push_back({ i - 1,i,"X" });
	}
	Rep1(i, 102, 201) {
		v.push_back({ i,i + 1,"Y" });
	}
	rep1(i, a) {
		rep1(j, b) {
			bool ansed = false;
			rep(l, 101) {
				rep(r, 101) {
					int z = d[i][j] - l * i - r * j;
					if (z < 0)continue;
					bool f = true;
					rep1(i_, a) {
						rep1(j_, b) {
							int sum = i_ * l + j_ * r + z;
							if (sum < d[i_][j_])f = false;
						}
					}
					if (f) {
						int sta = 1 + l;
						int goa = 202 - r;
						if (!exi[sta][goa])v.push_back({ sta,goa,to_string(z) });
						exi[sta][goa] = true;
						ansed = true;
						break;
					}
				}
				if (ansed)break;
			}
			if (!ansed)valid = false;
		}
	}
	if (!valid) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		cout << 202 << " " << v.size() << endl;
		rep(i, v.size()) {
			cout << v[i].from << " " << v[i].to << " " << v[i].cost << endl;
		}
		cout << "1 202" << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}

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

int main(){
  vector<int> data(3);
  for(int i = 0; i < 3; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  int count;
  if((data.at(2)*2)%2 == (data.at(0) + data.at(1))%2){
    count = (data.at(2)*2 - data.at(0) - data.at(1))/2;
  }
  else{
    count = ((data.at(2) + 1)*3 - data.at(0) - data.at(1) - data.at(2))/2;
  }
  cout << count << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll N,M;
ll H[200005];
vector<ll> G[200005];
bool f[200005];

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

    cin >> N >> M;

    for (int i = 0;i < N;i++){
        cin >> H[i+1];
    }

    for (int i = 0;i < M;i++){
        ll a,b; cin >> a >> b;

        if(H[a] == H[b]) f[a] = f[b] = true;
        if(H[a] > H[b]) f[b] = true;
        if(H[a] < H[b]) f[a] = true;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll ans = 0;

    for (int i = 1;i <= N;i++){
        if(f[i] == false) ans++;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 12732
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N, A;
    cin >> N >> A;
 
    int b = N % 500;
    if (b <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("../input.txt","r",stdin);

    string S;
    cin >> S;
    if(S[3-1] == S[4-1] && S[5-1] == S[6-1]) cout << "Yes\n";
    else cout << "No\n";


}

Measured memory_bytes: 3620
/**
 *    author:  zjsdut
 *    created: 2020/03/29 18:14:41
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define rep(n)                                                                 \
  for (int TOKENPASTE2(_iter_, __LINE__) = 0,                                  \
                               TOKENPASTE2(_num_, __LINE__) = (int)(n);        \
       TOKENPASTE2(_iter_, __LINE__) < TOKENPASTE2(_num_, __LINE__);           \
       ++TOKENPASTE2(_iter_, __LINE__))
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL && !defined DUIPAI
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n;
  scan(n);
  println((n + 1)/2);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL n,d,i,ans=0;cin>>n>>d;
      fo(i,0,n){
        LL x,y;cin>>x>>y;
        long double a=sqrt(x*x+y*y);
        if(a<=d) ans++;
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

const int N = 1e5 + 1, mod = 1e9 + 7;

int n, m, total = 0, h[N], deg[N];
bool nc[N];
vector<int> adj[N];
vector<pair<int, int>> ans;

void dfs(int v, int p) {
	for (auto u : adj[v]) {
		if (u == p) {
			continue;
		}
		if (h[u] == 0) {
			h[u] = h[v] + 1;
			dfs(u, v);
		}
		if (!nc[u] && (h[u] == h[v] + 1 || (h[u] && h[u] < h[v]))) {
			deg[v]++;
			ans.push_back({v, u});
		}
	}
	if (h[v] > 1 && (deg[v] & 1)) {
		deg[v]++;
		ans.push_back({v, p});
		nc[v] = 1;
	}
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 1, u, v; i <= m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	h[1] = 1;
	dfs(1, 0);
	for (int v = 1; v <= n; v++) {
		if (deg[v] % 2 == 0) {
			total++;
		}
	}
	if (total != n) {
		cout << -1;
		return 0;
	}
	for (auto cur : ans) {
		cout << cur.first << ' ' << cur.second << '\n';
	}
}

Measured memory_bytes: 18036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 44;
int n;
ll dp[N+1];

ll fib(int n) {
  if (n <= 1) return 1LL;
  return dp[n]>0 ? dp[n] : dp[n] = fib(n-1) + fib(n-2);
}

int main() {
  memset(dp, 0, sizeof(dp));
  scanf("%d ", &n);
  printf("%lld\n", fib(n));
  return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
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; }

int n;
int main() {
    cin >> n;
    vector<int> p(n, 0);
    vector<int> q(n, 0);
    for(int i = 0; i < n; ++i) cin >> p.at(i);
    for(int i = 0; i < n; ++i) cin >> q.at(i);

    vector<int> ppl(n, 0);
    for(int i = 0; i < n; ++i) ppl.at(i) = i+1;

    int now = 0;
    int a, b;
    do {
        bool flg = true;
        bool flg2 = true;
        for(int i = 0; i < n; ++i) {
            if(ppl.at(i) != p.at(i)) {
                flg = false;
                break;
            }
        }
        if(flg) a = now;
        for(int i = 0; i < n; ++i) {
            if(ppl.at(i) != q.at(i)) {
                flg2 = false;
                break;
            }
        }
        if(flg2) b = now;
        now++;
    }while(next_permutation(ppl.begin(), ppl.end()));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
    string s;
    string r("");
    cin >> s;

    int i;

    for (i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            r += s[i];
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 512
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define ld long double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

int a[N], dp[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[1] = 0;
	for(int i = 2; i <= n; i++) {
		dp[i] = inf;
		for(int j = 1; j < min(i, k + 1); j++) {
			dp[i] = min(dp[i], abs(a[i - j] - a[i]) + dp[i - j]);
		}
	}
	cout << dp[n];
}

Measured memory_bytes: 1024
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


int main(){
    long long X;
    cin >> X;

    long long cur = 100;
    int ret = 0;
    while(cur < X){
        cur *= 1.01;
        ++ret;
    }

    cout << ret;
}



Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))

s = 0
count1 = 0
for i in range(n):
    s+=a[i]
    if i%2==1:
        if s<=0:
            count1 += -s + 1
            s = 1
    else:
        if s>=0:
            count1 += s + 1
            s = -1


s = 0
count2 = 0
for i in range(n):
    s+=a[i]
    if i%2==0:
        if s<=0:
            count2 += -s + 1
            s = 1
    else:
        if s>=0:
            count2 += s + 1
            s = -1

print(min(count1,count2))

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  string a,b,c;
  int i,j;
  cin >> a >> b >> c;
  i = a.size();
  j = b.size();
  if (a[i-1] == b[0] && b[j-1] == c[0]){
    cout << "YES\n";
  }
  else{
    cout << "NO\n";
  }
  return 0;
} 

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        int[] h = new int[N];
        int ch=-1;
        for(int i=0; i<N; i++){
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
            h[i]=sc.nextInt();
            if(ch<0 && h[i]>0){
                ch = i;
            }
        }
        int resX, resY, resH;
        

        for(int i=0; i<=100; i++){
            for(int j=0; j<=100; j++){
                boolean a=true;
                int Cx = i;
                int Cy = j;
                int H = h[ch] + Math.abs(x[ch]-Cx) + Math.abs(y[ch]-Cy);
                for(int k=0; k<N; k++){
                    int karih = Math.max(H - Math.abs(x[k]-Cx) - Math.abs(y[k]-Cy),0);
                    if(karih!=h[k]){
                        a = false;
                        break;
                    }
                }

                if(a){
                    System.out.println(Cx + " " + Cy + " " + H);
                    return;
                }
            }
        }
        
        
        }
    }

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

int main() {
  
  int N; cin >> N; double sum = 0.0;
  
  vector<pair<double, double>> vec(N);
  
  for (int i = 0; i < N; i++) {
    
    double x, y; cin >> x >> y;
    
    vec[i].first = x; vec[i].second = y;
    
  }
  
  sort(begin(vec), end(vec));
  
  do {
    
    for (int i = 0; i < N - 1; i++) {
      
      double difX = vec[i].first - vec[i + 1].first;
      
      double difY = vec[i].second - vec[i + 1].second;
      
      double tmpX = pow(difX, 2); double tmpY = pow(difY, 2);
      
      sum += pow(tmpX + tmpY, 0.5);
      
    }
    
  } while (next_permutation(begin(vec), end(vec)));
  
  int route = 1;
  
  for (int i = 1; i <= N; i++) route *= i;
  
  cout << fixed << setprecision(10);
  
  cout << sum / route << endl;
  
}

Measured memory_bytes: 384
M = 1_000_000_007
H, W, A, B = gets.split.map(&:to_i)

def modPow(x, n)
  if n == 0
    1
  elsif n & 1 == 0
    modPow(x * x % M, n >> 1)
  else
    x * modPow(x * x % M, n >> 1) % M
  end
end

y = H - A - 1 
x = B
n1 = x + y 
n2 = H + W - n1 -2

Mod_frac = [1, 1]
(2..[n1, n2].max).each do |i|
  Mod_frac[i] = i * Mod_frac[i - 1] % M
end

Mod_inverse = Mod_frac.map{|x| modPow(x, M - 2)}

def nCr(n, r)
  Mod_frac[n] * Mod_inverse[r] * Mod_inverse[n - r] % M
end

tot = 0 
while y >= 0 && x < W
  tot += nCr(n1, x) * nCr(n2, W - x - 1)
  tot %= M
  y -= 1 
  x += 1 
end
puts tot


Measured memory_bytes: 4424
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

const ll mod = 1e9 + 7;

void decompPrimepair(ll n, vector<pll> &ans)
{
  ll check = 0;
  while (n % 2 == 0)
  {
    check++;
    n /= 2;
  }
  ans.push_back(pll{2, check});

  ll m = sqrt(n);
  ll i = 3;
  while (true)
  {
    if (n == 1)
    {
      break;
    }
    if (i > m)
    {
      ans.push_back(pll{n, 1});
      break;
    }
    if (n % i == 0)
    {
      ll check = 0;
      while (n % i == 0)
      {
        check++;
        n /= i;
      }
      m = sqrt(n);
      ans.push_back(pll{i, check});
    }
    i += 2;
  }
}

ll power_ll_p(ll a, ll b, ll p)	//F_pでのべき
{
  if (b > p)
  {
    b %= (p - 1);//位数p-1
  }
  if (b == 0)
  {
    return 1;
  }
  if (b % 2 == 0)
  {
    ll t = power_ll_p(a, b / 2, p);
    return t * t % p;
  }
  else
  {
    return a * power_ll_p(a, b - 1, p) % p;
  }
}

ll extgcd(ll a, ll b, ll&x, ll&y)
{
  if (b == 0)
  {
    x = 1;
    y = 0;
    return a;
  }
  else
  {
    ll q = a / b;
    ll g = extgcd(b, a - q * b, x, y);
    ll z = x - q * y;
    x = y;
    y = z;
    return g;
  }
}

//modp逆元
ll inversemod(ll a, ll p)
{
  ll x, y;
  extgcd(a, p, x, y);
  x %= p;
  if (x < 0)
  {
    x += p;
  }
  return x;
}

int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  ll a[10010];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    ans += inversemod(a[i], mod);
    ans %= mod;
  }

  vector<pll> v(0);
  decompPrimepair(a[0], v);
  for (int i = 1; i < n; i++)
  {
    int size = v.size();
    for (int j = 0; j < size; j++)
    {
      ll check = 0;
      ll p = v[j].first;
      while (a[i] % p == 0)
      {
        check++;
        a[i] /= p;
      }
      v[j].second = max(check, v[j].second);
    }
    vector<pll> u(0);
    decompPrimepair(a[i], u);
    v.insert(v.end(), u.begin(), u.end());
  }

  ll l = 1;
  int size = v.size();
  for (int j = 0; j < size; j++)
  {
    l *= power_ll_p(v[j].first, v[j].second, mod);
    l %= mod;
  }
  ans *= l;
  ans %= mod;
  cout << ans << "\n";
}

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main(){
int mountain[10];
int i,max,k,j;
for(i=0;i<10;i++)
cin>>mountain[i];
for(k=0;k<3;k++){
max=mountain[0];
for(i=1;i<=9;i++)
if(max<mountain[i])
{max=mountain[i];
 j=i;
}
cout<<max<<endl;
mountain[j]=-1;
}
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define     bit_1(a)       __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     pb             push_back
#define     pf             push_front
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     vstr           vector<string>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))
#define     orderset1      tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define     orderset2      tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
/// lcm(a,b)=a/gcd(a,b)*b (handle overflow)

bool sortinrev1(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second>b.second);
    else return (a.first > b.first);
}
bool sortinrev2(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second<b.second);
    else return (a.first > b.first);
}
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};


int main()
{
    string str;
    cin>>str;
    int maxx=-1;
    for(int i=0;i<str.size();){
        if(str[i]=='R'){
            int cnt=0;
            while(str[i]=='R'){
                cnt++;
                i++;
                if(i==str.size())break;
            }
            maxx=max(cnt,maxx);
        }
        else i++;
    }
    if(maxx==-1)cout<<0<<endl;
    else
    cout<<maxx<<endl;
}



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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> v(n),a(5);
  rep(i,n){
    cin >> v[i];
    if(v[i] % 4 == 0){
      a[4]++;
    }
    else if(v[i] % 2 == 0){
      a[2]++;
    }
    else{
      a[1]++;
    }
  }
  if(a[2] >= 1 && a[1] > 1)
    a[4] -= 1;
  if(a[1] > 0 && a[4])--a[1];
  a[4] -= a[1];
  if(a[4] < 0){
    std::cout << "No" << std::endl;
  }
  else{
    std::cout << "Yes" << std::endl; 
  }
  return 0;
}


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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> v(h);
  for(int i=0; i<h; i++){
    cin>>v[i];
  }
  vector<int> h_flag(h);
  vector<int> w_flag(w);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(v[i][j]=='#'){
        h_flag[i] = 1;
      }
    }
  }

  for(int j=0; j<w; j++){
    for(int i=0; i<h; i++){
      if(v[i][j]=='#'){
        w_flag[j] = 1;
        break;
      }
    }
  }
  
  for(int i=0; i<h; i++){
	int flag = 0;
    for(int j=0; j<w; j++){
      if(h_flag[i] == 1 && w_flag[j] == 1){
        cout<<v[i][j];
        flag = 1;
      }
    }
    if(flag == 1)cout<<endl;
  }

  
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.println(s.substring(0, s.length() - 8));
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

using vi = std::vector<int>;

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

    int n; std::cin >> n;
    vi v(n);
    for (auto &a : v) std::cin >> a;
    int p = n - 1;
    while (p >= 0) {
        std::cout << v[p] << " ";
        p -= 2;
    }
    p = p == -1 ? 0 : 1;
    while (p < n) {
        std::cout << v[p] << " ";
        p += 2;
    }
    std::cout << std::endl;
}


Measured memory_bytes: 2944
s=input()
d={'b':'d','d':'b','p':'q','q':'p'}
if len(s)%2!=0:
    print("No")
else:
    flag=True
    for idx in range(len(s)//2):
        if d[s[idx]]!=s[-idx-1]:
            print("No")
            flag=False
            break
    if flag:
        print("Yes")
    



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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

vector<pair<int,int>> g[20];

int main(){
    int N; cin >> N;
    for(int i=0;i<N;i++){
        int a; cin >> a;
        for(int j=0;j<a;j++){
            int x,y; cin >> x >> y;
            x--;
            g[i].push_back({x,y});
        }
    }
    int ans=0;
    for(int bit=0;bit<(1<<N);bit++){
        vector<bool> check(N,0);
        vector<int> res;
        for(int i=0;i<N;i++){
            if(bit&(1<<i)){
                check[i]=1;
                res.push_back(i);
            }
        }
        bool flag=true;
        for(auto k:res){
            for(auto j:g[k]){
                if(check[j.first]!=j.second) flag=false;
            }
        }
        if(flag) ans=max(ans,(int)res.size());
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    long long int N;
    cin >> N;

    long long int answer=0;
    long long int ratio = 0;
    for (long long int i=1; i<=N; i++){
        ratio = N / i;
        answer += i * (ratio * (ratio + 1)) / 2;
    }
    cout << answer << endl;
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
   int n, a[100], count = 0;
   cin >> n;
   for(int i = 0; i < n; i++) cin >> a[i];
   for(int i = 0; i < n; i++) {
	   for(int j = n-1; j >= i+1; j--) {
		   if(a[j] < a[j-1]) {
			   count++;
			   int temp = a[j];
			   a[j] = a[j-1];
			   a[j-1] = temp;
		   }
	   }
   }
   for(int i = 0; i < n; i++) {
	   if(i == 0) cout << a[i];
	   else cout << " " << a[i];
   } cout << endl;
   cout << count << endl;
   return 0;

}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

const int mod = 1e9 + 7;
void add(int &x, int y) {
    x += y;
    x %= mod;
}

int mul(int x, int y) {
    return (llong)x * y % mod;
}

int pw(int x, int p) {
    int r = 1;
    while (p) {
        if (p & 1) r = mul(r, x);
        x = mul(x, x);
        p >>= 1;
    }
    return r;
}

int fac[1000001];
int rev[1000001];

int nCr(int n, int r) {
    if (r < 0 || n < r) return 0;
    return mul(fac[n], mul(rev[r], rev[n - r]));
}

int nHr(int n, int r) {
    return nCr(n + r - 1, r);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    fac[0] = 1;
    for (int i = 1; i <= n; ++i) fac[i] = mul(fac[i - 1], i);
    rev[n] = pw(fac[n], mod - 2);
    for (int i = n; i > 0; --i) rev[i - 1] = mul(rev[i], i);
    int ans = 1;
    for (int k = 0; k * 3 <= n - 1; ++k)
        add(ans, mul(nHr(k + k + 2, n - 1 - k * 3), n - 1));
    for (int k = 0; k * 3 <= n - 2; ++k)
        add(ans, mul(nHr(k + k + 2, n - 2 - k * 3), mul(n - 1, n - 1)));
    printf("%d\n", ans);
    return 0;
}

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

typedef long long int llint;

int main()
{
  llint a, b, c, k;
  cin>> a >> b >> c >> k;

  if(k % 2) cout<< b - a <<endl;
  else      cout<< a - b <<endl;
  

  return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
n, oddness = [int(item) for item in input().split()]
# Oddness must be even
if oddness % 2 ==  1:
    print(0)
    exit()
oddness //= 2
max_oddness = n*n + n
max_pending = n + 1

dp = [[[0] * (max_oddness) for _ in range(max_pending)] for _ in range(n)]
dp[0][0][0] = 1
dp[0][1][1] = 1
oddness_itr = [item for item in range(n*n)]
for i in range(1, n):
    for j in range(i+1):
        # Too many pending items 
        if j > n // 2:
            break
        for k in oddness_itr:
            # Connect in line
            # Oddness increase by num of pending item
            dp[i][j][k+j] += dp[i-1][j][k]
            # Choose 1 from pending items
            dp[i][j][k+j] += dp[i-1][j][k] * j*2 
            dp[i][j][k+j] %= MOD
            # Choose 2 from pending items
            if j > 0:
                dp[i][j-1][k+j-1] += dp[i-1][j][k] * j*j
                dp[i][j-1][k+j-1] %= MOD 
            # Do nothing 
            dp[i][j+1][k+j+1] += dp[i-1][j][k] 
            dp[i][j+1][k+j+1] %= MOD 

print(dp[n-1][0][oddness])

Measured memory_bytes: 94556
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
const int maxn=500000+10;
set<int> s[30];
char ch[maxn];
int main(){
	int n,q;
	cin>>n>>ch+1>>q;
	for(int i=1;i<=n;i++){
		s[ch[i]-'a'].insert(i);
	}
	while(q--){
		int t,x;cin>>t;
		if(t==1){
			char cc;cin>>x>>cc;
			if(ch[x]!=cc) s[ch[x]-'a'].erase(x);
			ch[x]=cc;
			s[cc-'a'].insert(x);
		}
		else{
			int ans=0,ll,rr;
			cin>>ll>>rr;
			for(int i=0;i<26;i++){
				if(*s[i].lower_bound(ll)>=ll&&*s[i].lower_bound(ll)<=rr) ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define mod 1000000007
#define inf 999999999

int main(){
  int h,w;
  string s[55];
  cin >> h >> w;
  rep(i,h) cin >> s[i];

  rep(y,h){
    rep(x,w){
      if(s[y][x]=='#'){
        if(y>=h-1 || s[y+1][x] == '.')
        if(x>=w-1 || s[y][x+1] == '.')
        if(y<1 || s[y-1][x]  == '.')
        if(x<1 || s[y][x-1] == '.'){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

      System.out.println(Math.min(a * n, b));
    } finally {
      sc.close();
    }
  }
}


Measured memory_bytes: 35608
n = int(input())
a = list(map(int, input().split()))

a.sort()
acum = [0] * (n+1)
for i in range(n):
    acum[i+1] += acum[i] + a[i]

ans = 1

for i in reversed(range(1, n)):
    if a[i] <= 2 * acum[i]:
        ans += 1
    else:
        break

print(ans)

Measured memory_bytes: 14320