akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;

int main(){
  int i,j;
  int n,t;
  cin>>n>>t;
  vector<P> v(n);
  for(i=0;i<n;i++){
    cin>>v[i].fi>>v[i].se;
  }
  sort(v.begin(),v.end());
  ll ans=-1;
  VI dp(t+3010,0);
  for(i=0;i<n;i++){
    for(j=t-1;j>=0;j--){
      dp[j+v[i].fi]=max(dp[j+v[i].fi],dp[j]+v[i].se);
      ans=max(ans,dp[j+v[i].fi]);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h,w;
	cin>>h>>w;
	string s[h+1];
	int verti[w][h][2];
	int hori[h][w][2];
	memset(hori,0,sizeof(hori));
	memset(verti,0,sizeof(verti));
	for(int i=0;i<h;i++)
	{
		cin>>s[i];
	}
	for(int i=0;i<h;i++)
	{
		if(s[i][0]=='.')
		{
			hori[i][0][0]=1;
		}
		if(s[i][w-1]=='.')
		{
			hori[i][w-1][1]=1;
		}
		for(int j=1;j<w;j++)
		{
			if(s[i][j]=='#')
			{
				hori[i][j][0]=0;
			}
			else
			{
				hori[i][j][0]=hori[i][j-1][0]+1;
			}
		}
		for(int j=w-2;j>=0;j--)
		{
			if(s[i][j]=='#')
			{
				hori[i][j][1]=0;
			}
			else
			{
				hori[i][j][1]=hori[i][j+1][1]+1;
			}
		}
	}
	for(int i=0;i<w;i++)
	{
		if(s[0][i]=='.')
		{
			verti[i][0][0]=1;
		}
		if(s[h-1][i]=='.')
		{
			verti[i][h-1][1]=1;
		}
		for(int j=1;j<h;j++)
		{
			if(s[j][i]=='#')
			{
				verti[i][j][0]=0;
			}
			else
			{
				verti[i][j][0]=verti[i][j-1][0]+1;
			}
		}
		for(int j=h-2;j>=0;j--)
		{
			if(s[j][i]=='#')
			{
				verti[i][j][1]=0;
			}
			else
			{
				verti[i][j][1]=verti[i][j+1][1]+1;
			}
		}
	}
	int fans=0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(s[i][j]=='.')
			{
				int ans=hori[i][j][0]+hori[i][j][1]+verti[j][i][0]+verti[j][i][1]-3;
				fans=max(fans,ans);
			}
		}
	}
	cout<<fans<<endl;
	return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = min(n, m/2);
  m -= ans*2;
  ans += m/4;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> p[i];
	}

	auto ans = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (i + 1 == p[i])
		{
			++ans;
			++i;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int E[200][200] = { 0 };
int r[8];

int rec(int R, int A[],int x) {
	int l = 1e+9, s[8];
	if (R == 0) {
		return 0;
	}
	REP(i, R) {
		s[i] = A[i];
	}

	int t;
	REP(i, R) {
		int tmp = s[i];
		s[i] = s[R - 1];
		s[R - 1] = tmp;
		if (x == 8) {
			t = rec(R - 1, s, tmp);
		}
		else {
			t = E[r[x]][r[tmp]] + rec(R - 1, s, tmp);
		}
		s[R - 1] = s[i];
		s[i] = tmp;
		l = min(l, t);
	}

	return l;

}

int main() {
	int N, M, R, a, b, c, ans = 1e+9, A[8];

	REP(i, 200) {
		REP(j, 200) {
			if (i != j) {
				E[i][j] = 20000001;
			}
		}
	}

	cin >> N >> M >> R;
	REP(i, R) {
		cin >> a;
		r[i] = a - 1;
		A[i] = i;
	}
	REP(i, M) {
		cin >> a >> b >> c;
		E[a - 1][b - 1] = c;
		E[b - 1][a - 1] = c;
	}

	REP(k, N) {
		REP(i, N) {
			REP(j, N) {
				if (E[i][j] > E[i][k] + E[k][j]) {
					E[i][j] = E[i][k] + E[k][j];
				}
			}
		}
	}
	
	ans = rec(R, A, 8);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();

    int[] L = new int[N];

    for (int i=0; i<N; i++) {
      L[i] = sc.nextInt();
    }

    Arrays.sort(L);

    int sum = 0;
    for (int i=0; i<N-1; i++) {
      sum += L[i];
    }

    System.out.println(L[N-1] < sum ? "Yes" : "No");

  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,x,a=0,y;
    vector<long long int>v;
    cin>>n;

    cin>>x;
    y=x;
    v.push_back(x);
    for(i=0;i<n-1;i++)
    {
        cin>>x;
        if(y<x)
        {
            x-=1;
            y=x;
        }
        v.push_back(x);
    }

    if(v[0]>v[1])
        v[0]=v[0]-1;

    for(i=1;i<n;i++)
    {
        if(v[i]>=v[i-1])
            a++;
    }

    if(a==n-1 || n==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

int main(){
  int n;
  int a[110][110];
  int up[110];
  int down[110];
  cin >> n;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
      if(i == 0) up[j] = a[i][j];
      else down[j] = a[i][j];
    }
  }
  for(int i = 0; i < n-1; i++) up[i+1] += up[i];
  int ans = 0;
  for(int i = 0; i < n; i++){
    int res = up[i];
    for(int j = i; j < n; j++) res += down[j];
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

    long long a[n],b[n],c[n];

    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=n-1;i>0;i--){
        a[i-1]+=max(b[i],c[i]);
        b[i-1]+=max(a[i],c[i]);
        c[i-1]+=max(a[i],b[i]);
    }
    cout<<max(a[0],max(b[0],c[0]));
}


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


int main(){
  /*
  ll temp=5;
  rep(i,4){
    cout<<((1<<i)&temp)<<endl;
  }
  */
  ll h,w,k;
  cin>>h>>w>>k;

  vector<string> v(h);
  rep(i,h)cin>>v[i];
  ll ans=0;
  rep(i,(1<<h)){
    rep(j,(1<<w)){
      ll cnt=0;
      rep(q,h)rep(z,w){
        if (v[q][z]=='.')continue;
        /*
        cout<<i<<"h"<<j<<"w"<<endl;
        cout<<q<<"q"<<z<<"z"<<endl;
        cout<<((1<<q)&i)<<" "<<((1<<z)&j)<<endl;
        */
        if ((1<<q)&i and (1<<z)&j){
          cnt++;
        }
      }
    //  cout<<cnt<<"cnt"<<endl;
      if (cnt==k)ans++;
    }
  }
cout<<ans;

}


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

using namespace std;

int main()
{
  int N;
  long long A[200001];
  long long dp[200001][2];
  
  scanf("%d", &N);
  
  for (int i = 1; i <= N; i++) {
    scanf("%lld", A + i);
  }
  
  dp[0][0] = dp[0][1] = 0;
  dp[1][0] = 0;
  dp[1][1] = A[1];
  dp[2][0] = max(A[1], A[2]);
  
  long long odd_sum = A[1];
  for (int i = 3; i <= N; i++) {
    if (i % 2 == 1) {
      odd_sum += A[i];
      dp[i][1] = odd_sum;
      dp[i][0] = max({dp[i - 1][0], dp[i - 2][1], A[i] + dp[i - 2][0]});
    }
    else {
      dp[i][0] = max({dp[i - 1][1], dp[i - 2][0] + A[i], dp[i - 3][1] + A[i]});
    }
  }
  
  
  printf("%lld\n", dp[N][0]);
  
  return 0;
}

Measured memory_bytes: 8500
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep2(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) rep2(i,0,n)
#define pb push_back

int n,x[24],y[24],r[24],c[24];
map<int,int> M;
map<int,int>::iterator it;

bool insec(int a,int b){
	return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])<(r[a]+r[b])*(r[a]+r[b]);
}

int f(int s){
	it=M.find(s);
	if(it!=M.end())return M[s];
	int res=0,top[24];
	fill(top,top+n,1);
	rep(i,n)rep(j,i)if(insec(i,j)&&((s>>j)&1))top[i]=0;
	rep(i,n)rep(j,i){
		if(top[i]&&top[j]&&((s>>i)&1)&&((s>>j)&1)&&c[i]==c[j])res=max(res,f(s-(1<<i)-(1<<j))+2);
	}
	return M[s]=res;
}

int main(){
	while(cin>>n&&n){
		M.clear();
		rep(i,n)cin>>x[i]>>y[i]>>r[i]>>c[i];
		cout<<f((1<<n)-1)<<endl;
	}
}

Measured memory_bytes: 32000
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m,k = readInts()
A = [0] + list(accumulate(readInts()))
B = list(accumulate(readInts()))
ans = 0
import bisect
#print(B)
for i in range(len(A)):
    if A[i] > k:
        continue
    x = bisect.bisect_left(B,k - A[i] + 1)
    #print(x,)
    ans = max(ans,x+i)
print(ans)


Measured memory_bytes: 46428
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
point = 0
prev = -1
for i in range(n):
    point += b[a[i]-1]
    if prev+1 == a[i]:
        point += c[a[i-1]-1]
    prev = a[i]
print(point)

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

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

template<class T> bool chmin(T& a,T b){ if(a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a,T b){ if(a < b){ a = b; return true; } return false; }
/*
 * Modint struct
 * library author : @snuke
 * */
const int mod = 1e9 + 7;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct Combination{
    const int MAX = 2000050;
    vector<mint> fact;
    vector<mint> finv;
    Combination():fact(MAX),finv(MAX){
        for(int i = 0;i < MAX;i++){
            if(i == 0)fact[i] = (mint)1;
            else fact[i] = fact[i-1]*(mint)i;
        }
        finv[MAX - 1] = fact[MAX - 1].inv();
        for(int i = MAX - 2;i >= 0;i--){
            finv[i] = finv[i + 1] * (mint)(i + 1);
        }
    }
    mint comb(int n,int r){
        if(r==0)return 1;
        if(n<0||r<0||n<r)return 0;
        else return fact[n]*finv[r]*finv[n-r];
    }
};

Combination  C;

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

    int64_t k;cin >> k;
    string s;cin >> s;

    int64_t m = k + s.size();

    mint ans = 0;

    for(int last = 0;last <= k;last++){
       ans += C.comb(m - last - 1,s.size() - 1) * mint(25).pow(k - last) * mint(26).pow(last);
    }

    cout << ans << '\n';
}


Measured memory_bytes: 35516
k, n = map(int, input().split())


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

L = 0

for i in range(n-1):
  M = A[i+1] - A[i]
  if M > L:
    L = M
      
M = (k-A[n-1]) + A[0]
if M > L:
  L = M
  
print(k-L)


Measured memory_bytes: 77260
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   A.cpp                                              :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: kotaro666 <kotaro0726@gmail.com>           +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/03/04 11:21:39 by kotaro666         #+#    #+#             */
/*   Updated: 2020/03/04 12:01:17 by kotaro666        ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B + C >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
H,W,M = map(int,input().split())
bombs=set(tuple(map(lambda x:int(x)-1,input().split())) for _ in range(M))

HD=defaultdict(int)
WD=defaultdict(int)
for h,w in bombs:
    HD[h]+=1
    WD[w]+=1

HMAX=max(HD.values())
WMAX=max(WD.values())
ans_min=HMAX+WMAX-1

h_cand=set()
w_cand=set()
for h in range(H):
    if HD[h]==HMAX:
        h_cand.add(h)

for w in range(W):
    if WD[w]==WMAX:
        w_cand.add(w)

for h in h_cand:
    for w in w_cand:
        if (h,w) not in bombs:
            print(ans_min+1)
            exit()
print(ans_min)



Measured memory_bytes: 205964
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=readline()
    println(ifelse(n[1]==n[3],"Yes","No"))
end
main()

Measured memory_bytes: 108260
S=input()
L=len(S)

for i in range(2,L,2):
  #print(S[0:(L-i)//2], S[(L-i)//2:(L-i)])
  if S[0:(L-i)//2]==S[(L-i)//2:(L-i)]:
    print(L-i)
    break

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll H;
    cin >> H;
    ll now = 2;
    if(H == 1) {
        cout << "1" << endl;
        exit(0);
    }
    for (int i = 0; i < 40; i++) {
        now *= 2;
        if(H < now){
            cout << now-1 << endl;
            exit(0);
        }
    }
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	vector<P> point(n);
	rep(i, n){
		int x, y;
		cin >> x >> y;
		point[i] = P(x, y);
	}
	
	map<P, int> mp;
	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			int p = point[i].first - point[j].first;
			int q = point[i].second - point[j].second;
			mp[P(p, q)]++;
			mp[P(-p, -q)]++;
		}
	}
	
	int mx = 0;
	for(auto it_point : mp){
		mx = max(mx, it_point.second);
	}
	
	cout << n - mx << endl;
	return 0;
}



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

#define ll long long
#define pb push_back

using namespace std;

int main()
{

    string s, a;
    int cnt  = 0;
    cin >> s >> a;
    for(int i = 0; i < s.length(); i++)
          if( s[i] == a[i])cnt++;
    cout << cnt << endl;
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  
  if (N[0]==N[1] && N[1]==N[2]) {
    cout << "Yes" << endl;
  }
  else if (N[1]==N[2] && N[2]==N[3]) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

ll calc(ll l, ll r){
    if(l >= r) return 1;
    r -= l;
    ll dp[2][r+1];
    dp[0][0] = 1; dp[1][0] = 0;
    for(int i = 1; i <= r; i++){
        dp[0][i] = dp[0][i-1] + dp[1][i-1];
        dp[1][i] = dp[0][i-1];
    }
    return dp[0][r] + dp[1][r];
}

int main(void){
    int H, W, K; cin >> H >> W >> K;
    ll dp[H+1][W]; rep(i, H+1) rep(j, W) dp[i][j] = 0;
    K--;
    dp[0][0] = 1;
    if(W >= 3){
        for(int i = 1; i <= H; i++){
            for(int j = 0; j < W; j++){
                //自分の場所とは無関係な位置に線が引けることを忘れない
                //自分の左にはj本、右にはW-1-j本の線がある
                if(j == 0){
                    dp[i][j] = dp[i-1][0]*calc(1, W-1) + dp[i-1][1]*calc(2, W-1);
                }
                else if(j == W-1){
                    dp[i][j] = dp[i-1][W-1]*calc(0, W-2) + dp[i-1][W-2]*calc(0, W-3);
                }
                else if(j == 1){
                    //右にW-2本 左に1本
                    dp[i][j] = dp[i-1][j-1]*calc(2, W-1) + dp[i-1][j]*calc(2, W-1) + dp[i-1][j+1]*calc(3, W-1);
                }
                else if(j == W-2){
                    dp[i][j] = dp[i-1][j-1]*calc(0, W-4) + dp[i-1][j]*calc(0, W-3) + dp[i-1][j+1]*calc(0, W-3);
                }
                else{
                    //右にW-j-1本 左にj本
                    dp[i][j] = dp[i-1][j-1]*calc(0, j-2)*calc(j+1, W-1) + dp[i-1][j]*calc(0, j-1)*calc(j+1, W-1) + dp[i-1][j+1]*calc(0, j-1)*calc(j+2, W-1);
                }
                dp[i][j] %= mod;
            }
        }
    }
    else if(W == 1){
        dp[H][0] = 1;
    }
    else{
        for(int i = 1; i <= H; i++){
            dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod;
            dp[i][1] = (dp[i-1][0] + dp[i-1][1]) % mod;
        }
    }

    cout << dp[H][K] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
const int N=4000000+10;
bitset<N> B;
int n,a[N];
int main(){
    B[0]=1;
    scanf("%d",&n); int sum=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]); sum+=a[i];
        B=B|(B<<a[i]);
    }   
    int x=(sum+1)/2;
    while(B[x]==0) x++;
    printf("%d\n", x);
}

Measured memory_bytes: 1792
n, m = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i).sort.reverse
sum = arr.inject(:+)
ok = true
(0...m).each do |i|
  ok = ok && arr[i] * (4 * m) >= sum
end
puts ok ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int fac[1000005],invfac[1000005];
int N,A,B,C;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &a,int b) {
    a = inc(a,b);
}
int cnm(int n,int m) {
    if(n < m) return 0;
    else return mul(fac[n],mul(invfac[m],invfac[n - m]));
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
        if(c & 1) res = mul(res,t);
        t = mul(t,t);
        c >>= 1;
    }
    return res;
}
void Solve() {
    read(N);read(A);read(B);read(C);
    A = mul(A,fpow(100,MOD - 2));
    B = mul(B,fpow(100,MOD - 2));
    C = mul(C,fpow(100,MOD - 2));
    int iv = fpow(inc(1,MOD - C),MOD - 2);
    C = mul(C,iv);
    int k = fpow(inc(A,B),MOD - 2);
    A = mul(A,k);B = mul(B,k);
    fac[0] = 1;
    for(int i = 1 ; i <= 2 * N ; ++i) {
        fac[i] = mul(fac[i - 1],i);
    }
    invfac[2 * N] = fpow(fac[2 * N],MOD - 2);
    for(int i = 2 * N - 1 ; i >= 0 ; --i) {
        invfac[i] = mul(invfac[i + 1],i + 1);
    }
    int ans = 0;
    for(int i = 0 ; i < N ; ++i) {
        int h = inc(mul(fpow(A,N),fpow(B,i)),mul(fpow(B,N),fpow(A,i)));
        int t = mul(cnm(i + N - 1,N - 1),mul(C + 1,i + N));
        t = mul(t,h);
        update(ans,t);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define pb push_back
 
 
ll max(ll a,ll b)
{
    if(a>=b)
    return a;
    
    else
    return b;
}
 
int main(){
ll n,k;
  cin>>n>>k;
  vector<ll>v;
  
  while(n--)
  {
    ll temp;
    cin>>temp;
    v.pb(temp);
  }
  
  n=v.size();
  
  sort(v.begin(),v.end());
  ll sum=0;
  for(ll i=0;i<max(n-k,0);i++)
  sum+=v[i];
  
  cout<<sum;
}

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

int main(void){
    long long n, k;
    cin >> n >> k;
    
    if(k == 0){
        cout << n * n << endl;
        return 0;
    }
    
    long long ans = 0;
    long long mod;
    long long i;
    for(i = k + 1; i <= n; i++){
        mod = n % i;
        if(mod >= k){
            ans += n / i * (i - k) + (mod - k + 1);
        }else{
            ans += n / i * (i - k);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        if(n == 1 )return 1;
        
        int i=2;
        while(true) {
            if(i * 2 > n) return i;
            i *= 2;
        }
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>                                          // This will work only for g++ compiler.
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)             // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)            // 1 based indexing
#define forab(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n)-1; i >= 0; --i)         // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)           // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define __builtin_popcount(x) ones(x)
#define __builtin_popcountl(x) onesl(x)
#define __builtin_popcountll(x) onesll(x) // to be used with algorithms that processes a container Eg: find(all(c
#define all(x) (x).begin(), (x).end()     //Forward traversal
#define rall(x) (x).rbegin, (x).rend()    //reverse traversal
#define tr(c, i) for (__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define sz(a) int((a).size())
#define Fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define InputOuput                    \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll linf = 1e18L + 5;
const int inf = 1e9 + 5;
const int mod = 1e9 + 7;

int md(int x)
{
    return ((x % mod) + mod) % mod;
}
int main()
{
  //  InputOuput;
    Fast;
    int n, m;
    cin >> n >> m;
    vvi mat(n + 1, vi(m + 1, -1));
    for1(i, n)
        for1(j, m)
    {
        char k;
        cin >> k;
        if (k == '.')
            mat[i][j] = 0;
    }

    vvi dp(n + 1, vi(m + 1, 0));
    dp[1][1] = 1;
    for1(i, n)
    {
        for1(j, m)
        {
            if (i == 1 && j == 1)
                ;
            else
            {
                if (mat[i][j] == 0)
                    dp[i][j] = md(md(dp[i - 1][j]) + md(dp[i][j - 1]));
            }
           // cout << dp[i][j] << ' ';
        }
        //cout << '\n';
    }
    cout << dp[n][m] << '\n';
    return 0;
}

Measured memory_bytes: 11048
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
using namespace std;
int main()
{
     int n,cnt=0,x;
     cin>>n;
     for(int i=1;i<=n;i++)
  {
      cin>>x;
      if(i%2&&x%2)
        cnt++;
  }
  cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3520
#include <iostream>
using namespace std;
int counter(string S){
    int cnt = 0;
    for(int i = 0 ; i < 3 ; ++i){
        if(S[i] == 'R'){
            cnt ++;
        }
    }
    return cnt;
}

int main(void){
    string S;
    cin >> S;
    int c;
    c = counter(S);
    if(!S.compare("RSR")){
        cout << 1 << endl;
    }else{
        cout << c << endl;
    }
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N;
    cin >> N;
    ll ans = 1;
    vector<ll>v(3, 0);
    rep(i, N){
        ll A;
        cin >> A;
        ll cnt = 0;
        rep(j, 3)if(A == v[j])cnt++;
        ans = (ans * cnt) % MOD;
        rep(j, 3)if(A == v[j]){
            v[j]++;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split()))

INF = 10 ** 18

dp = [[0] * (N) for _ in range(N)]

for i in range(N):
    A[i + 1] += A[i]

for j in range(1, N):
    for i in range(N - j):
        tmp = INF
        for k in range(i, i + j):
            # print (i, i + j, k + 1)
            tmp = min(tmp, dp[i][k] + dp[k + 1][i + j])
        dp[i][i + j] = tmp + A[i + j + 1] - A[i]

print (dp[0][N - 1])


Measured memory_bytes: 42732
object Main {
  def main(args:Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val A = List.fill(N)(sc.nextInt)
    val n_odd = A.filter(_%2 == 1).length
    val n_even = A.filter(_%2 == 0).length
    if (n_odd%2 == 0) println("YES")
    else println("NO")
  }
}


Measured memory_bytes: 49256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = 998244353LL;
const double pi = acos(-1.0);

bool Check(int x, int y) {
	return x >= 0 && y >= 0 && x < 10 && y < 10;
}

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

int main() {
	VVI p(10, VI(10));
	int x, y, s; char cha;
	while (cin >> x >> cha >> y >> cha >> s) {
		int c = s == 1 ? 5 : s == 2 ? 9 : 14;
		rep(i, c) {
			int X = x + dx[i], Y = y + dy[i];
			if (Check(X, Y))p[Y][X]++;
		}
	}

	int cnt = 0, ma = -1;
	rep(i, 10)rep(j, 10) {
		ma = max(ma, p[i][j]);
		cnt += p[i][j] == 0;
	}
	Cout(cnt);
	Cout(ma);
}


Measured memory_bytes: 3120
// 2020-07-17 00:56:53
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int used[100005];
void answer() {
  int n;
  cin >> n;
  vector<ll> s(n);
  rep(i, n) cin >> s[i];
  ll ans = 0;
  REP(c, 1, n/2) {
    memset(used, 0, sizeof used);
    ll cur = 0;
    int l = 0, r = n-1;
    for(;;) {
      if(used[l] || used[r] || l == r || r < c) break;
      used[l] = used[r] = 1;
      cur += s[l] + s[r];
      chmax(ans, cur);
      l += c, r -= c;
    }
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4524
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a[50],b[50],c[50],d[50],ans,p[10];
void dfs(int l, int pre){
    if(l==n){
        int s=0;
        for(int i=0;i<q;i++)if(p[b[i]-1]-p[a[i]-1]==c[i])s+=d[i];
        ans=max(ans,s);
        return;
    }
    for(int i=pre;i<=m;i++){
        p[l]=i;
        dfs(l+1,i);
    }
}
int main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(0,1);
    cout<<ans;
}


Measured memory_bytes: 3584
import numpy as np

n, k = map(int, input().split())
hhh = list(map(int, input().split()))
hhh = np.array([0] + hhh, dtype=np.int64)
INF = 10 ** 18
dp = np.full((n + 1, k + 1), fill_value=INF, dtype=np.int64)
dp[0, 0] = 0
for i, h in enumerate(hhh[1:], start=1):
    ndp = np.full((n + 1, k + 1), fill_value=INF, dtype=np.int64)
    ndp[:n, 1:] = dp[:n, :-1]
    ndp[i] = (dp + np.maximum(0, h - hhh)[:, np.newaxis]).min(axis=0)
    dp = ndp

print(dp.min())


Measured memory_bytes: 14660
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var ais = CRL().ArrayLongs();
        var flag = ais.Count(x => x < 0).IsEven();
        var sum = ais.Sum(x => Math.Abs(x));
        CWL(sum - (flag ? 0 : ais.Min(x => Math.Abs(x)) * 2));
    }
}

public static partial class Program
{
    //テンプレここから
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static string RL() => ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static void WL(object obj) => WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);

    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    //テンプレここまで
}

Measured memory_bytes: 29404
#include<iostream>
#include<vector>
#include<algorithm>

const int INF = 1<<25;

using namespace std;

int main()
{
	int n,m,i,j;
	int cost[101][101],time[101][101];
	
	for(;;)
	{
		cin >> n >> m ;
		if(n==0 && m==0)
			break;
		
		for(i=0;i<m+1;i++)
		{
			for(j=0;j<m+1;j++)
			{
				if(i!=j)
					cost[i][j]=time[i][j]=INF;
				else
					cost[i][j]=time[i][j]=0;
			}
		}
		
		for(i=0;i<n;i++)
		{
			int a,b,co,ti;
			cin >> a >> b >> co >> ti ;
			cost[a][b]=cost[b][a]=co;
			time[a][b]=time[b][a]=ti;
		}
		
		int inp;
		cin >> inp ;
		
		for(int k=0;k<m+1;k++)
		{
			for(i=0;i<m+1;i++)
			{
				for(j=0;j<m+1;j++)
				{
					cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
					time[i][j]=min(time[i][j],time[i][k]+time[k][j]);
				}
			}
		}
		
		for(i=0;i<inp;i++)
		{
			int st,en,se;
			cin >> st >> en >> se ;
			
			if(se==0)
				cout << cost[st][en] << endl;
			else
				cout << time[st][en] << endl;
		}
	}
}

Measured memory_bytes: 944
import java.util.*;
public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());


        int[][] pointsX = new int[N][D];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                pointsX[i][j] = Integer.parseInt(sc.next());
            }
        }

        int count = 0;
        for (int i = 1; i < N; i++) {
            
            for (int j = 0; j < i; j++) {
              	long sum = 0;
                for (int j2 = 0; j2 < D; j2++) {
                    sum += Math.abs(pointsX[i][j2]-pointsX[j][j2]) * Math.abs(pointsX[i][j2]-pointsX[j][j2]);
                }

                if (Math.sqrt(sum) % 1 == 0) {
                    count++;
                }
            }
        }

        System.out.println(count);
    }
}

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

int main(){
   double n,y;
   while(cin >> n){
      y=pow(n/9.8,2)*4.9;
      if(y/5>(int)y/5) 
      cout << (int)y/5+2 << endl;
      else cout << (int)y/5+1 << endl;
   }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h> <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if ((a==b && c!=a)|| (a==c && b!=a) || (c==b && b!=a))
        cout<<"Yes";
    else
       cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <fstream>
#include <string>
#include <time.h>
#include <ctime>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cstdlib>
using namespace std;

long long cnt;
int v,j;
vector<int> G;
int n,A[1000000];

void insertionSort(int A[],int n,int g){
	
	

	for(int i=g;i<n;i++){
		v = A[i];
		j = i-g;
		while(j>=0&&A[j]>v){
			A[j+g] = A[j];
			j = j-g;
			cnt++;
		}
		A[j+g] = v;
	}
	
}

void shellSort(int A[],int n){
	cnt = 0;
	
	
	for(int h=1;;){
		if(h>n)break;
		G.push_back(h);
		h = 3*h+1;
	}


	for(int i=G.size()-1;i>=0;i--){
		insertionSort(A,n,G[i]);
	}
	cout << G.size() << endl;
	for(int i=G.size()-1;i>=0;i--){
		cout << G[i];
		if(i)cout << ' ';
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0;i<n;i++){
		cout << A[i] << endl;
	}
}

int main(){

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

	return 0;
}

Measured memory_bytes: 5124
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++) cin>>arr[i][j];
	}
	int dp[n][3];
	for(int i=0;i<3;i++){
		dp[0][i]=arr[0][i];
	}
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  vector<bool> tate(H, false) ;
  vector<bool> yoko(W, false) ;
  
   for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
    cin >> data.at(i).at(j) ;
    }
   }
  
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (data.at(i).at(j) == '#') {
				tate.at(i) = true;
				yoko.at(j) = true;
			}
		}
	}

for (int i = 0; i < H; i++) {	
   if (tate.at(i)){
	 for (int j = 0; j < W; j++) {
		if ( yoko.at(j)) {
			cout << data.at(i).at(j);
		}
	 }
     cout << endl;
   }					
}
  
}
  


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s = new Scanner(System.in);
		double n = Math.sqrt(s.nextDouble());
		n = Math.floor(n);
		System.out.println((int)Math.pow(n, 2));
		
	}
}

Measured memory_bytes: 24660
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
using namespace std;
int main()
{
 	int a,b,c;
 	cin>>a>>b>>c;
 	if(a==5&&b==5&&c==7)
	 {
		cout<<"YES"<<endl;
     }
    else if
	(a==5&&c==5&&b==7)
	{
	cout<<"YES"<<endl;
    }
	else if
	(a==7&&b==5&&c==5)
    { 
	cout<<"YES"<<endl;
	}
	else 
	cout<<"NO"<<endl; 
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

int main(){
	ll X, Y;
	cin >> X >> Y;

	int cnt = 0;
	while (X <= Y){
		X *= 2;
		cnt++;
	}
	cout << cnt << endl;
}

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

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		char[][] S = new char[H][W];
		for(int i = 0; i < H; i++) {
			String Si = sc.next();
			for(int j = 0; j < W; j++) S[i][j] = Si.charAt(j);
		}
		// initialize
		int[][] L = new int[H][W], R = new int[H][W], U = new int[H][W], D = new int[H][W];
		for(int i = 0; i < H; i++) {
			Arrays.fill(L[i], 0);
			Arrays.fill(R[i], 0);
			Arrays.fill(U[i], 0);
			Arrays.fill(D[i], 0);
		}

		// Left
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(S[i][j] == '#') continue;
				L[i][j] = 1;
				if(j != 0) L[i][j] += L[i][j - 1];
			}
		}
		// Right
		for(int i = 0; i < H; i++) {
			for(int j = W - 1; j >= 0; j--) {
				if(S[i][j] == '#') continue;
				R[i][j] = 1;
				if(j != W - 1) R[i][j] += R[i][j + 1];
			}
		}
		// Up
		for(int i = 0; i < W; i++) {
			for(int j = 0; j < H; j++) {
				if(S[j][i] == '#') continue;
				U[j][i] = 1;
				if(j != 0) U[j][i] += U[j - 1][i];
			}
		}
		// Down
		for(int i = 0; i < W; i++) {
			for(int j = H - 1; j >= 0; j--) {
				if(S[j][i] == '#') continue;
				D[j][i] = 1;
				if(j != H - 1) D[j][i] += D[j + 1][i];
			}
		}
		int max = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(S[i][j] == '.') max = Math.max(max, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
			}
		}
		System.out.println(max);

	}
}

Measured memory_bytes: 112872
/**
 * @jakestrj
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define rep(i, j, k) for(int i=(j);i<(k);++i)
#define repi(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>(k);--i)
#define peri(i, j, k) for(int i=(j);i>=(k);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(), greater<int>()
#define mem(a, b) memset(a, (b), sizeof(a))
#define mem2(a, b) memset(a, (b), sizeof(a[0][0])*len(a)*len(a[0]))
#define sz(x) ((int)(x).size())
#define len(x) (int)(sizeof(x)/sizeof(x[0]))
#define endl "\n"
//#define INF 1e18
#define EPS 1e-9
#define PI 2*acos(0)
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
typedef tuple<int, int, int> trio;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef map<int,int> mpii;
typedef set<int> si;

const int INF = 1e9+10;
const int MN = 1e5+10;
int dp[MN];
struct A {
	void solve(std::istream& cin, std::ostream& cout) {
		fill(dp, dp+MN, INF);
	    int n; cin >> n;
	    vi h(n);
	    rep(i, 0, n){
	        cin >> h[i];
	    }
	    dp[0]=0; //dp(stone 0 to stone 0)
	    rep(i, 0, n){
	        for(auto& j : {i+1, i+2}){
	            if(j<n){
	                dp[j] = min(dp[j], dp[i]+abs(h[j]-h[i]));
	            }
	        }
	    }
	    cout << dp[n-1] << endl;
	}
};


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>

using namespace std;

namespace
{

}

#if 1
int main()
{
	int n;
	cin >> n;

	if (n == 1)
	{
		printf("Hello World\n");
	}
	else if (n == 2)
	{
		int a, b;
		cin >> a >> b;
		printf("%d", a + b);
	}
}
#endif


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  ll n, k;
  scanf("%lld%lld", &n, &k);
  set<ll> s;
  s.insert(n % k);
  n %= k;
  while (1) {
    if (s.find(k - n) != s.end()) {
      break;
    } else {
      n = k - n;
      s.insert(n);
    }
  }
  printf("%lld\n", *s.begin());
}

Measured memory_bytes: 256
#coding:utf-8

n = list(input())

if n[0] == n[1] and n[1] == n[2]:
  print('Yes')
elif n[1] == n[2] and n[2] == n[3]:
  print('Yes')
elif n[0] == n[1] and n[1] == n[2] and n[2] == n[3]:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_i32_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn dfs(i: &mut i32, switches_condition: &Vec<Vec<i32>>, p_vec: &Vec<i32>, switches: &mut Vec<bool>, count: &mut i32) {
    if *i == switches.len() as i32 {
        // println!("{:?}", switches);
        let mut flag = true;
        for light_idx in 0..switches_condition.len() {
            let mut switch_count = 0;
            for target in &switches_condition[light_idx] {
                if switches[(target - 1) as usize] == true {
                    switch_count += 1;
                }
            }
            if switch_count % 2 != p_vec[light_idx] {
                flag = false;
                break;
            }
        }
        if flag {
            *count += 1;
        }
        return;
    }
    switches[*i as usize] = true;
    dfs(&mut (*i + 1), switches_condition, p_vec, switches, count);
    switches[*i as usize] = false;
    dfs(&mut (*i + 1), switches_condition, p_vec, switches, count);
}

fn main() {
    let (n, m) = input_int_tuple();
    let mut switches_condition: Vec<Vec<i32>> = Vec::new();
    for i in 0..m {
        let mut condition = input_i32_vec();
        condition.remove(0);
        switches_condition.push(condition);
    }
    // println!("{:?}", switches_condition);
    let p_vec = input_i32_vec();
    let mut count = 0;
    dfs(&mut 0, &switches_condition, &p_vec, &mut vec![false; n as usize], &mut count);
    println!("{}", count);
}


Measured memory_bytes: 4352
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import Control.Monad

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

medians :: [Int] -> (Int, Int)
medians xs = (xs' !! (half - 1), xs' !! half)
  where xs' = sort xs
        half = length xs `div` 2

main :: IO ()
main = do
  getLine
  xs <- getInts
  let (m1, m2) = medians xs
  forM_ xs $ \x ->
  	print $ if x < m2 then m2 else m1

Measured memory_bytes: 52476